Path: blob/main/core/coreutils/src/compat/compat.h
1067 views
/*1* compat.h2* Local prototype definitions for functions put together in this library.3* We don't have the full OpenBSD system headers, so use this header file4* to be a placeholder.5*/67/*8* Reference from Apple's archived OS X (now macOS documentation9* we need to import this else we are going to get a "declaration expected at10* line 29"11*12* including types.h allows us to fix erros in the mget declaration13*14*/1516#ifndef COWASM_COMPAT_H17#define COWASM_COMPAT_H1819#include "posix-wasm.h"20#include <unistd.h>21#include <string.h>22#include <stddef.h>23#include <sys/types.h>24#include <sys/stat.h>2526/* setmode.c */27mode_t getmode(const void *, mode_t);28void *setmode(const char *);2930/* strmode.c */31void strmode(int, char *);3233/* pwcache.c */34/* Darwin (OSX/macOS) requires the nouser and nogroup35to be added */3637#if defined __APPLE__38const char *user_from_uid(uid_t, int nouser);39const char *group_from_gid(gid_t, int nogroup);40int uid_from_user(const char *, uid_t *);41int gid_from_group(const char *, gid_t *);42#else43const char *user_from_uid(uid_t, int);44const char *group_from_gid(gid_t, int);45int uid_from_user(const char *, uid_t *);46int gid_from_group(const char *, gid_t *);47#endif4849/* logwtmp.c */50void logwtmp(const char *, const char *, const char *);5152/* fmt_scaled.c */53int scan_scaled(char *, long long *);54int fmt_scaled(long long, char *);5556/* getbsize.c */57char *getbsize(int *, long *);5859/* devname.c */60char *devname(dev_t, mode_t);6162/* heapsort.c */63int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));6465/* recallocarray.c */66void *recallocarray(void *, size_t, size_t, size_t);6768/* reallocarray.c */69#if defined __APPLE__70void *reallocarray(void *ptr, size_t nmemb, size_t size);71#endif7273/* strlcat.c */74#if defined __linux75size_t strlcat(char *, const char *, size_t);76#endif7778/* strlcpy.c */79#if defined __linux__80size_t strlcpy(char *, const char *, size_t);81#endif8283/*84* MAXBSIZE does not exist on Linux however, since Darwin is an OS85* that derives from FreesBD this does exist on Darwin, so we dont86* need to get oursevels, an extra warning for redefining a macro,87* however this is the explainaition for Linux because filesystem block size88* limits are per filesystem and not consistently enforced across89* the different filesystems. If you look at e2fsprogs and its90* header files, you'll see the max block size is defined as 6553691* via (1 << EXT2_MAX_BLOCK_LOG_SIZE) where EXT2_MAX_BLOCK_LOG_SIZE92* is 16. On OpenBSD, MAXBSIZE is simply (64 * 1024), which is93* 65536. So we'll just define that here so as to avoid having94* bsdutils depend on e2fsprogs to compile.95*/96#if !defined __APPLE__97#define MAXBSIZE (64 * 1024)98#endif99100/*101* fmt_scaled(3) specific flags.102* This comes from lib/libutil/util.h in the OpenBSD source.103*/104#define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */105106/* Buffer sizes */107#define _PW_BUF_LEN sysconf(_SC_GETPW_R_SIZE_MAX)108#define _GR_BUF_LEN sysconf(_SC_GETGR_R_SIZE_MAX)109110/* Defined in progname.c */111extern void setprogname(const char *progname);112extern const char *__progname;113114#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)115116#define OFF_MAX LLONG_MAX /* max value for an off_t */117#define MAP_NOCORE 0x00020000118#define MAP_NOSYNC 0x0800119120#define __FBSDID(x)121#define __DECONST(a, v) ((a)(v))122123#endif // COWASM_COMPAT_H124125