short ref, links to source files.
Only functions defined are going to be built.
To define them, either do (for, e.g. puts) #define mini_puts
before you include minilib.h
Or, use the config script.: mini_puts
Some functions define other functions, these will be listed in the line,
starting with Define:
An example, using the scripting config, is given below: (miniputs.c)
#if 0 mini_start mini_puts LDSCRIPT text_and_bss INCLUDESRC shrinkelf return #endif int main(){ puts("Hello, world!"); return(0); }
compile with ./minimake --config miniputs.c -o miniputs miniputs.c
(what compiles to an annoying size of 251 Bytes here. Something again bloats. replacing the puts with writes, there still are 208 Bytes. This used to be 151 Bytes. Have to sort this out.)
- assert
-
+ Defines: memcpy write kill rt_sigaction getpid
(../macros/assert.h l.4)ctype.h
- ctype_functions
-
#ifdef mini_ctype_functions
(../include/ctype.h l.23)
create functions instead of macros for isalpha, .., isprint
the ctype macros are defined also without being explicitely enabled.declarations.h
- accept
-
accept( int fd, struct sockaddr *upeersockaddr, int *upeeraddrlen) + (../include/syscall_stubs.h l.247) manpage: accept
- bind
-
bind( int fd, struct sockaddr *umyaddr, int addrlen) + (../include/syscall_stubs.h l.241) manpage: bind
- chmod
-
chmod( const char *filename, mode_t mode) + (../include/syscall_stubs.h l.201) manpage: chmod
- clone
-
clone( int clone_flags, unsigned long stack, void *parent_tid, void *child_tid) + (../include/syscall_stubs.h l.225)
- dup3
-
dup3(int oldfd, int newfd, int flags) + (../include/syscall_stubs.h l.121) manpage: dup3
- execveat
-
execveat( int dirfd, const char filename, char const* argv, char* const* envp, int flags) + (../include/syscall_stubs.h l.173)
- fchmod
-
fchmod( unsigned int fd, mode_t mode) + (../include/syscall_stubs.h l.117) manpage: fchmod
- fchown
-
fchown( unsigned int fd, uid_t user, gid_t group) + (../include/syscall_stubs.h l.116) manpage: fchown
- fcntl
-
fcntl( unsigned int fd, unsigned int cmd, unsigned long arg) + (../include/syscall_stubs.h l.178) manpage: fcntl
- flock
-
flock( unsigned int fd, unsigned int cmd) + (../include/syscall_stubs.h l.130) manpage: flock
- fstat
-
fstat(int fd,struct stat* statbuf) + (../include/syscall_stubs.h l.111) manpage: fstat
- getcwd
-
getcwd( char *buf, unsigned long size) + (../include/syscall_stubs.h l.123) manpage: getcwd
- getdents
-
getdents( unsigned int fd, struct dirent *direntry, unsigned int count ) + (../include/syscall_stubs.h l.106) manpage: getdents
- getitimer
-
getitimer( int which, struct itimerval *value) + (../include/syscall_stubs.h l.265) manpage: getitimer
- getppid
-
DEF_syscall(getppid,0) + (../include/syscall_stubs.h l.204) manpage: getppid
- getresuid
-
getresuid( uid_t *ruid, uid_t *euid, uid_t *suid) + (../include/syscall_stubs.h l.210) manpage: getresuid
- getrlimit
-
getrlimit( unsigned int resource, struct rlimit *rlim) + (../include/syscall_stubs.h l.231) manpage: getrlimit
- getrusage
-
getrusage( int who, struct rusage *ru) + (../include/syscall_stubs.h l.142) manpage: getrusage
- getsid
-
getsid( pid_t pid) + (../include/syscall_stubs.h l.164) manpage: getsid
- getsockopt
-
getsockopt( int fd, int level, int optname, char *optval, int *optlen) + (../include/syscall_stubs.h l.245) manpage: getsockopt
- gettimeofday
-
gettimeofday( struct timeval *a1, struct timezone *a2) + (../include/syscall_stubs.h l.147) manpage: gettimeofday
- inotify_add_watch
-
inotify_add_watch( int fd, const char *pathname, u32 mask) + (../include/syscall_stubs.h l.220)
- inotify_init
-
DEF_syscall(inotify_init,0) + (../include/syscall_stubs.h l.219)
- inotify_init1
-
inotify_init1( int flags) + (../include/syscall_stubs.h l.222)
- inotify_rm_watch
-
inotify_rm_watch( int fd, __s32 wd) + (../include/syscall_stubs.h l.221)
- kill
-
kill( pid_t pid, int sig) + (../include/syscall_stubs.h l.136) manpage: kill
- listen
-
listen( int fd, int backlog) + (../include/syscall_stubs.h l.248) manpage: listen
- lstat
-
lstat(const char* filename,struct stat* statbuf) + (../include/syscall_stubs.h l.113) manpage: lstat
- memfd_create
-
memfd_create( const char *uname_ptr, unsigned int flags) + (../include/syscall_stubs.h l.191)
- mknod
-
mknod( const char *filename, umode_t mode, unsigned dev) + (../include/syscall_stubs.h l.259) manpage: mknod
- mount
-
mount( char *dev_name, char *dir_name, char *type, unsigned long flags, void *data) + (../include/syscall_stubs.h l.184) manpage: mount
- mprotect
-
mprotect( POINTER *a1, POINTER a2, int a3 ) + Returns: *a1
(../include/syscall_stubs.h l.254) manpage: mprotect - msync
-
msync( void* addr, size_t len, int flags) + (../include/syscall_stubs.h l.262) manpage: msync
- munmap
-
munmap( void* addr, size_t len) + (../include/syscall_stubs.h l.261) manpage: munmap
- nanosleep
-
nanosleep( struct timespec *rqtp, struct timespec *rmtp) + (../include/syscall_stubs.h l.146) manpage: nanosleep
- pivot_root
-
pivot_root( const char *new_root, const char *put_old) + (../include/syscall_stubs.h l.156)
- prctl
-
prctl( int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) + (../include/syscall_stubs.h l.274)
- readahead
-
readahead( int fd, loff_t offset, size_t count) + (../include/syscall_stubs.h l.258)
- readlink
-
readlink( const char *path, char *buf, int bufsiz) + (../include/syscall_stubs.h l.127) manpage: readlink
- reboot
-
reboot( int magic1, int magic2, unsigned int cmd, void *arg) + (../include/syscall_stubs.h l.182) manpage: reboot
- recvfrom
-
recvfrom( int fd, void *ubuf, size_t size, unsigned flags, struct sockaddr *addr, unsigned int *addr_len) + (../include/syscall_stubs.h l.236) manpage: recvfrom
- rt_sigaction
-
rt_sigaction( int sig, const struct sigaction *act, struct sigaction *oact, size_t sigsetsize) + (../include/syscall_stubs.h l.152)
- rt_sigprocmask
-
rt_sigprocmask( int how, sigset_t *nset, sigset_t *oset, size_t sigsetsize) + (../include/syscall_stubs.h l.186)
- rt_sigreturn
-
rt_sigreturn( unsigned long __unused) + (../include/syscall_stubs.h l.153)
- rt_sigsuspend
-
rt_sigsuspend( const sigset_t *mask, size_t sigsetsize); + (../include/syscall_stubs.h l.188)
- sendfile
-
sendfile( int out_fd, int in_fd, off_t *offset, size_t count) + (../include/syscall_stubs.h l.181) manpage: sendfile
- sendto
-
sendto( int fd, void *buff, size_t len, unsigned flags, struct sockaddr *addr, int addr_len) + (../include/syscall_stubs.h l.239) manpage: sendto
- setgroups
-
setgroups( int gidsetsize, gid_t *grouplist) + (../include/syscall_stubs.h l.199) manpage: setgroups
- setitimer
-
setitimer( int which, struct itimerval *value, struct itimerval *ovalue) + (../include/syscall_stubs.h l.264) manpage: setitimer
- setresuid
-
setresuid( uid_t *ruid, uid_t *euid, uid_t *suid) + (../include/syscall_stubs.h l.211) manpage: setresuid
- setreuid
-
setreuid( uid_t ruid, uid_t euid) + (../include/syscall_stubs.h l.163) manpage: setreuid
- setrlimit
-
setrlimit( unsigned int resource, struct rlimit *rlim) + (../include/syscall_stubs.h l.232) manpage: setrlimit
- setsockopt
-
setsockopt( int fd, int level, int optname, const void *optval, int optlen) + (../include/syscall_stubs.h l.243) manpage: setsockopt
- socket
-
socket( int family, int type, int protocol) + (../include/syscall_stubs.h l.229) manpage: socket
- splice
-
splice( int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) + (../include/syscall_stubs.h l.196)
- stat
-
stat(const char* filename,struct stat* statbuf) + (../include/syscall_stubs.h l.112) manpage: stat
- symlink
-
symlink( const char *oldname, const char *newname) + (../include/syscall_stubs.h l.126) manpage: symlink
- sync
-
DEF_syscall(sync,0) + (../include/syscall_stubs.h l.128) manpage: sync
- timerfd_create
-
timerfd_create( int clockid, int flags) + (../include/syscall_stubs.h l.268)
- timerfd_gettime
-
timerfd_gettime( int ufd, struct itimerspec *otmr) + (../include/syscall_stubs.h l.272)
- timerfd_settime
-
timerfd_settime( int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr) + (../include/syscall_stubs.h l.270)
- times
-
times( struct tms *info) + (../include/syscall_stubs.h l.149) manpage: times
- umask
-
umask( int mask) + (../include/syscall_stubs.h l.257) manpage: umask
- umount2
-
umount2( const char *mountpoint, int flags) + (../include/syscall_stubs.h l.180)
- uname
-
uname(struct new_utsname *name ) + (../include/syscall_stubs.h l.168) manpage: uname
- utime
-
utime( const char *filename, struct utimbuf *times) + (../include/syscall_stubs.h l.203) manpage: utime
- vfork
-
DEF_syscall(vfork,0) + (../include/syscall_stubs.h l.139) manpage: vfork
- vhangup
-
DEF_syscall(vhangup,0 ) + (../include/syscall_stubs.h l.166)
- wait4
-
wait4( pid_t upid, int *stat_addr, int options, struct rusage *ru) + (../include/syscall_stubs.h l.176) manpage: wait4
dirent.h
- closedir
-
int closedir(DIR *dir); + Defines: getbrk sys_brk
(../src/directories/closedir.c l.6) manpage: closedir - opendir
-
static DIR *opendir(const char *name ); + Defines: close dirbuf sys_brk getbrk open write 0
(../src/directories/opendir.c l.10) manpage: opendir - readdir
-
struct dirent *readdir(DIR *dir);
Defines: dirbuf getdents
(../src/directories/readdir.c l.10) manpage: readdir
read a directory.
return the next dirent, or 0, if the end is reached.
return 0 on error and set errno,
if mini_errno is not defined, return -errno on error - rewinddir
-
void rewinddir(DIR *dir); + (../src/directories/rewinddir.c l.2) manpage: rewinddir
- scandir
-
int scandir(const char *path, struct dirent listing[], int (*fp_select)(const struct dirent *), int (*cmp)(const struct dirent , const struct dirent ));
Defines: seterrno strlen sys_brk getbrk open memcpy kill getdents getpid errno write swap 0 dirbuf
(../src/directories/scandir.c l.30) manpage: scandir
list files and dirs in a directory
This implementation uses malloc_brk() for the dynamic allocation
of the listing, and tries to do as less copies as possible.
The dynamically allocated space for the result list (listing[])
is guaranteed to be at one continuous memory location.
if the select callback is 0, meaning all entries should be returned,
There are no copies done at all,
besides the copying from kernelspace to userspace.
To free the space, allocated for the listing,
either call free_brk(),
when no other allocations via malloc_brk took place.
Or save the brk before you call scandir,
and restore it after the call.
(e.g.)
long savebrk=getbrk();
int ret=scandir(…);
brk(savebrk);
Freeing single list entries might give unexpected results.
returns the number of the read entries,
or the negative errno on error. - seekdir
-
void seekdir(DIR *dir, long off); + (../src/directories/seekdir.c l.2) manpage: seekdir
- telldir
-
long telldir(DIR *dir); + (../src/directories/telldir.c l.2) manpage: telldir
fcntl.h
- mkfifo
-
static int mkfifo( const char* path, mode_t mode ); + (../include/mkfifo.h l.4) manpage: mkfifo
ioctl.h
- ioctl
-
int volatile ATTR_OPT("O0") ioctl( int fd, unsigned long int request, … ); + (../src/system/ioctl.c l.9) manpage: ioctl
mini_addons.h
- ALIGN
-
(../macros/alignment.h l.9)
macros for alignment.
They take a number or pointer, and align upwards to 2,4,8,..256
There are the macros ALIGN_2 ALIGN_4 ALIGN_8 …,
and ALIGN_P, which aligns to the size of a pointer. (8 for amd64) - OPTFENCE
-
#ifndef clang
(../include/syscall.h l.66)
prevent gcc to optimize away registers and variables
the macro OPTFENCE(…) can be invoked with any parameter.
The parameters will get calculated, even if gcc doesn’t recognize
the use of the parameters, e.g. cause they are needed for an inlined asm syscall.
The macro translates to an asm jmp and a function call to the function
opt_fence, which is defined with the attribute "noipa" -
(the compiler "forgets" the function body, so gcc is forced
to generate all arguments for the function)
The generated asm jump hops over the call to the function,
but this gcc doesn’t recognize.
This generates some overhead,
(a few (never reached) bytes for setting up the function call, and the jmp)
but I didn’t find any other solution,
which gcc wouldn’t cut for optimizations from time to time.
(volatile, volatile asm, optimize attributes,
andsoon have all shown up to be unreliable - sometimes(!)).
Had some fun debugging these bugs, which naturally showed up only sometimes.
(Many syscalls also work with scrambled arguments..)
And, I believe it IS a compiler bug.
Volatile should be volatile for sure, not only sometimes.
I mean, why the heck do I write volatile?? - OPTIMIZATIONS
-
(../include/config.h l.33)
enable some optimizations,
with a slitghtly bigger memory footprint.
defaults to off
(yet only calloc is optimized. todo) - _die
-
void _die();
(../src/process/die.c l.36)
internal implementation of die - _itobin
-
int _itobin(int i, char*buf, int prec, int groups ); + (../src/conversions/itobin.c l.8)
- _match
-
int _match(char *text, const char *re, text_match *st_match); + (../src/match/match.c l.96)
- _match_ext2
-
char* _match_ext2(char *text, char *re, void(*p_matched_cb)(int number, char *pos,int len), int(*p_wildcard_cb)(int number, char *match_char), text_match *st_match);
(../src/match/match_ext2.c l.326)
internal implementation of match_ext - _mprints
-
#define _mprints(…) dprints(STDOUT_FILENO, VA_ARGS) + Defines: write
(../include/prints.h l.10) - _strcasecmp
-
int _strcasecmp(const char*c1,const char*c2,int len); + Defines: tolower
(../src/string/strcasecmp.c l.5) - alphasort
-
int alphasort( const struct dirent de1, const struct dirent de2 );
Defines:
(../src/directories/alphasort.c l.7) manpage: alphasort
Sort dirents by name.
Deviating of the standard,
the asciitables is used for the comparison
(using strcmp) - ansicolors
-
(../include/ansicolors.h l.45)
defines for ansicolors at the console, 16 color mode
the names are:
AC_NORM ( white text on black background)
AC_BLACK
AC_RED
AC_GREEN
AC_BROWN
AC_BLUE
AC_MAGENTA
AC_MARINE (= AC_CYAN)
AC_LGREY
AC_WHITE
AC_GREY
AC_LRED
AC_LGREEN
AC_YELLOW
AC_LBLUE
AC_LMAGENTA
AC_LMARINE (= AC_LCYAN)
AC_LWHITE
AC_BGBLACK
AC_BGRED
AC_BGGREEN
AC_BGBROWN
AC_BGBLUE
AC_BGMAGENTA
AC_BGMARINE
AC_BGLGREY
AC_BGWHITE
AC_BOLD
AC_FAINT
AC_CURSIVE
AC_UNDERLINE
AC_LIGHTBG
AC_BLINK
AC_INVERTED
AC_INVERSE
( Faint to inverse are not available at every terminal ) - basename
-
char *basename(char *path); + (../src/directories/basename.c l.2) manpage: basename
- brk
-
static int brk( const void* addr );
Defines: sys_brk
(../src/memory/brk.c l.8) manpage: brk
set the brk to addr
return 0 on success.
conformant brk, when mini_errno is defined return -1 and set errno.
if errno isn’t available,
returns the negative errno value on error - bsd_cksum
-
unsigned int bsd_cksum( const char* p, unsigned int len );
(../src/file/cksum.c l.31)
bsd checksum - bsd_cksumblock
-
unsigned int bsd_cksumblock( unsigned int hash, const char* p, unsigned int len );
(../src/file/cksum.c l.20)
bsd checksum, called by bsd_cksum,
with initial hash value - bsd_definitions
-
(../include/bsd_definitions.h l.5)
definitions, found at BSD
enable with mini_bsd_definitions - bsd_timespec
-
(../include/bsd_timespec.h l.5)
timespec functions, copied from freebsd - cfmakeraw
-
void cfmakeraw(struct termios *tp); + Defines: termio
(../src/termios/cfmakeraw.c l.3) manpage: cfmakeraw - clone_t
-
int clone_t(int flags); + (../src/process/clone.c l.7)
- config
-
(../include/config.h l.6)
configuration settings, to be compiled statically.
System specific paths, maximums, etc go here.
Other values are within globaldefs.h;
architecture specific values are within the folder headers. - creat
-
int volatile creat( const char *s, int mode ); + Defines: open
(../src/file/creat.c l.5) manpage: creat - def
-
#define SETOPT_short( opts, option ) (;
(../macros/getoptm.h l.52)
Set a option flag(s) (bit(s)) manually.
param options: e.g. just a, or ( a+h+l) to check for several flags at once - die
-
#define die(errnum,msg) {ewritesl(msg);exit_errno(errnum);}
Defines: errno_str write execve exit
(../src/process/die.c l.11)
write msg to stderr and exit with failure
if errno is defined and set, /bin/errno is executed to give a verbose error
message
if errno is either not defined or not set,
exit with -1
- die_if
-
#define die_if( when, errnum, msg ) if( when ) die( errnum, msg )
Defines: errno_str write exit execve
(../src/process/die.c l.59)
when arg1 is true, write msg to stderr and exit with failure
if errno is defined and set, /bin/errno is executed to give a verbose error
message
if errno is either not defined or not set,
exit with -1
- dief
-
#define dief(errnum,fmt,…) {fprintf(stderr,fmt,VA_ARGS);exit_errno(errnum);}
Defines: getpid kill execve write errno_str fileno globals strlen exit
(../src/process/die.c l.20)
write fmt andargs via fprintf to stderr and exit with failure
if errno is defined and set, /bin/errno is executed to give a verbose error
message
if errno is either not defined or not set,
exit with -1
- dief_if
-
#define dief_if( when, errnum, fmt,… ) if( when ) dief( errnum, fmt, VA_ARGS )
Defines: write errno_str exit execve
(../src/process/die.c l.69)
when arg1 is true, vall dief(errnum,fmt)
if errno is defined and set, /bin/errno is executed to give a verbose error
message
if errno is either not defined or not set,
exit with -1
- dies
-
#define dies(errnum,…) {eprintsl(VA_ARGS);exit_errno(errnum);}
Defines: exit execve write errno_str
(../src/process/die.c l.30)
write variable string list to stderr and exit with failure
if errno is defined and set, /bin/errno is executed to give a verbose error
message
if errno is either not defined or not set,
exit with -1
- dies_if
-
#define dies_if( when, errnum, … ) if( when ) dies( errnum, VA_ARGS )
Defines: execve exit errno_str write
(../src/process/die.c l.80)
when arg1 is true, vall dies(errnum, … )
if errno is defined and set, /bin/errno is executed to give a verbose error
message
if errno is either not defined or not set,
exit with -1
- dirbuf
-
(../include/dirent.h l.7)
the switch for defining the dirbuf.
used internally - dirbuf_malloc
-
#ifndef mini_dirbuf_malloc
(../include/dirent.h l.31)
which malloc to use for allocating the dir handles
malloc : use malloc, therefore the minibuf
malloc_brk : use malloc_brk
defaults to malloc - dirbufsize
-
#ifndef mini_dirbufsize
(../include/dirent.h l.22)
the dir stream bufsize
The size of the buffer can be changed by setting mini_dirbufsize
to it’s size in Bytes. (default 2048)
The buffer is allocated via malloc,
therefore mini_buf must be set to a value greater than dirbufsize - dirfd
-
int dirfd(DIR *d); + (../src/directories/dirfd.c l.2) manpage: dirfd
- dirname
-
char *dirname(char *s); + Defines: strlen
(../src/directories/dirname.c l.8) manpage: dirname - djb2_hash
-
unsigned long djb2_hash(const unsigned char *str);
(../src/math/hashes.c l.12)
hashes, from d.j.Bernstein
(http://www.cse.yorku.ca/~oz/hash.html)
I’ve tested djb2_hash, and it gives quite good results.
I’m sure, Bernstein did think and test his algorithm sincerely.
When combining djb2_hash and sdbm_hash, the probability of collisions
might tend to zero.
Me I’m going this way. I guess. I might check djb2_hash for collisions within a space of around 8 digits.
The hash functions compute the hashes of a c string with a 0 at the end.
The cksum functions do work with a pointer and a given len. - djb_cksum
-
unsigned int djb_cksum( const char* p, unsigned int len );
(../src/file/cksum.c l.8)
checksum algorithm by d.j.bernstein.
Didn’t do any benchmarks, but the computation
might be quite performant.
It is a bitshift and two additions per byte. - dprintf
-
int dprintf( int fd, const char *fmt, … ); + Defines: getpid kill strlen write
(../src/output/dprintf.c l.5) manpage: dprintf - dprints
-
int dprints(int fd, const char *msg,…); + Defines: write
(../src/output/dprints.c l.14) - dtodec
-
int dtodec(double d, char* buf, int precision); + Defines: uitodec
(../src/conversions/dtodec.c l.10) - endgrent
-
void endgrent(); + Defines: pwent munmap
(../src/userdb/endgrent.c l.4) manpage: endgrent - endpwent
-
void endpwent(); + Defines: pwent munmap
(../src/userdb/endpwent.c l.4) manpage: endpwent - eprint
-
#define eprint(str) write(STDERR_FILENO,str,strlen(str))
Defines: strlen write
(../include/prints.h l.57)
write str to stderr. Needs strlen - eprintf
-
#define eprintf(fmt,…) fprintf(stderr, fmt, VA_ARGS)
Defines: write fileno strlen
(../include/prints.h l.133)
write fmt and arguments to stderr. - eprintfs
-
#define eprintfs(fmt,…) fprintfs(stderr, fmt, VA_ARGS)
Defines: strlen fileno write
(../include/prints.h l.128)
write fmt and arguments to stderr.
only format %s and %c are recognized - eprintl
-
#define eprintl() write(STDERR_FILENO,"\n",1)
Defines: write
(../include/prints.h l.66)
write a newline to stderr - eprints
-
#define eprints(…) dprints(STDERR_FILENO,VA_ARGS,0)
Defines: write
(../include/prints.h l.26)
print the string(s) supplied as arg(s) to stdout
this macro has an variable argument count. - eprintsl
-
#define eprintsl(…) dprints(STDERR_FILENO,VA_ARGS,"\n",0)
Defines: write
(../include/prints.h l.48)
print the string(s) supplied as arg(s) and newline to stderr - eputs
-
#define eputs(msg) ( eprint(msg) + eprintl() )
Defines: write strlen
(../include/prints.h l.76)
write msg to stderr, append a newline. Needs strlen. - err
-
#define err( status, fmt … ) { fprintf(stderr,fmt ); fprints(stderr,":",strerror(errno)); exit(status); }
Defines: strerror fileno write strlen exit globals kill getpid errno
(../src/process/error.h l.20) manpage: err
print an error message to stderr,
print an error message dependend on errno ( strerror(errno) ),
exit with status - errno_str
-
static char *errno_str(int err);
(../src/process/errno_str.c l.7)
convert errno to str, with 3 chars length
ending the string (global)
with two \0\0, when errno<100
errnum must be <200. - error
-
#define error( status, errnum, fmt … ) { fprintf(stderr,fmt ); if (errnum) fprints(stderr,":",strerror(errnum)); if ( status ) exit(status); }
Defines: strlen exit globals strerror fileno write kill getpid
(../src/process/error.h l.13)
print an error message to stderr
when errnum is not 0, print either the number,
or a verbose error message (with strerror),
when mini_verbose_errstr is defined.
(verbose error messages add aboyut 4kB)
when status is non null, terminate with status - errx
-
#define errx( status, fmt … ) { fprintf(stderr,fmt); exit(status); }
Defines: globals exit strlen write fileno getpid kill
(../src/process/error.h l.27) manpage: errx
print an error message to stderr,
exit with status - ether_ntoa
-
char* ether_ntoa( const struct ether_addr *e ); + Defines: network
(../src/network/ether_ntoa.c l.3) manpage: ether_ntoa - ewrites
-
#define ewrites(str) write(STDERR_FILENO,str,sizeof(str))
Defines: write
(../include/prints.h l.87)
write the constant str to stderr. Computes length with sizeof(str) at compile time. - ewritesl
-
#define ewritesl(str) write(STDERR_FILENO,str"\n",sizeof(str)+1)
Defines: write
(../include/prints.h l.100)
write the constant str to stderr, followed by a newline.
Computes length with sizeof(str) at compile time. - exit_errno
-
void exit_errno( int errnum );
Defines: write errno_str execve exit
(../src/process/exit_errno.c l.17)
exit, and execute /bin/errno
this is intended to give a error message for the
given errno num.
Instead of having the error messages compiled
into each binary, they can stay within one executable, "errno"
This spares about 4kB, but needs errno installed to /bin/errno
It’s the drawback of not having a shared library,
where all executables would share the same errno messages
in memory.
On the other hand, a shared library would need to be installed
as well.
The supplied errno can be negative,
the absolute value is supplied to errno. - fexecve
-
static inline int fexecve(int fd, char *const argv[], char *const envp[]); + (../include/fexecve.h l.3) manpage: fexecve
- fexecveat
-
static inline int fexecveat(int fd, char *const argv[], char *const envp[]); + (../include/fexecveat.h l.3)
- fgetsn
-
int fgetsn(char buf, int size, FILE F);
Defines: read fileno
(../src/streams/fgetsn.c l.4)
get a line like fgets, but return the len of the read string. - fgetsp
-
char* fgetsp(char buf, int size, FILE F);
Defines: read fileno
(../src/streams/fgetsp.c l.7)
read a line from F into buf with max chars size.
Return a pointer to the terminating 0 byte.
A terminating linebreak is not written to buf. - fgetud
-
unsigned int fgetud(FILE* F);
Defines: fileno read
(../src/streams/fgetud.c l.5)
read an unsigned integer from the stream F
reads all digits until a nondigit is read. - fgetul
-
unsigned long int fgetul(FILE* F);
Defines: fileno read
(../src/streams/fgetul.c l.5)
read an unsigned long integer from the stream F
reads all digits until a nondigit is read. - fprintfs
-
int fprintfs( FILE* F, char *fmt, …);
Defines: fileno write strlen
(../src/output/fprintfs.c l.8)
prints formatted and unbuffered output to the stream F.
only %s and %c are recognized.
no mini_buf or globals are used, so using fprintfs instead of fprintf can
save some sections / bytes. - fprints
-
#define fprints(F,…) dprints(fileno(F),VA_ARGS,0)
Defines: strlen fileno write
(../include/prints.h l.34)
print the string(s) supplied as arg(s) to stream
this macro has an variable argument count. - free_brk
-
int free_brk();
(../src/memory/freebrk.c l.9)
free all memory,
which has been allocated with malloc_brk.
Returns 0, if memory has been freed;
1, when there hasn’t been any memory allocations with
malloc_brk before.
Then brk() gives an error, return the return value of brk - fwrites
-
#define fwrites(fd,str) write(fd,str,sizeof(str))
Defines: write
(../include/prints.h l.107)
write the constant str to fd. Computes length with sizeof(str) at compile time. - fwritesl
-
#define fwritesl(fd,str) write(fd,str"\n",sizeof(str)+1)
Defines: write
(../include/prints.h l.114)
write the constant str to fd,followed by a newline.
Computes length with sizeof(str) at compile time. - getbrk
-
static long getbrk();
(../src/memory/getbrk.c l.6)
get the current brk
does either a syscall to brk,
or returns the globally saved var - getgrent
-
struct group* getgrent(); + Defines: userdb open pwent
(../src/userdb/getgrent.c l.4) manpage: getgrent - getgrgid
-
struct group *getgrgid(gid_t gid);
Defines: close open token_s token_i pwent setgrent write fstat globals userdb grent mmap
(../src/userdb/getgrgid.c l.7) manpage: getgrgid
get the group entry of the group "gid".
the last result is cached, multiple calls with the same
name will return the cached result. - getgrnam
-
struct group getgrnam(const char name);
Defines: setgrent write close pwent token_i token_s open globals mmap grent userdb fstat
(../src/userdb/getgrnam.c l.7) manpage: getgrnam
get the group entry of the group "name".
the last result is cached, multiple calls with the same
name will return the cached result. - getgrouplist
-
int getgrouplist(const char* user, gid_t group, gid_t *groups, int *ngroups);
Defines: token_i pwent passwdfile_open token_s open setgrent setpwent write mmap grent userdb
(../src/userdb/getgrouplist.c l.5) manpage: getgrouplist
needs rewrite.
now nonstandard. - getpwent
-
struct passwd* getpwent(); + Defines: userdb open
(../src/userdb/getpwent.c l.4) manpage: getpwent - getpwnam
-
struct passwd getpwnam(const char name);
Defines: write mmap globals pwent token_i fstat open token_s close
(../src/userdb/getpwnam.c l.7) manpage: getpwnam
get the passwd entry of the user "name".
the last result is cached, multiple calls with the same
name will return the cached result. - getpwuid
-
struct passwd *getpwuid(uid_t uid);
Defines: passwdfile_open pwent token_i open token_s write mmap setpwent
(../src/userdb/getpwuid.c l.7) manpage: getpwuid
get the passwd entry of the user with uid.
the last result is cached, multiple calls with the same
uid will return the cached result. - getusergroups
-
int getusergroups(const char* user, int maxgroups, int *list);
Defines: token_s open passwdfile_open pwent token_i userdb grent write mmap setpwent setgrent
(../src/userdb/getusergroups.c l.8)
get the supplementary groups for the user uid.
does not necessarily contain the primary group,
which is given in the passwd entry.
This function calls internally setgrent() and getgrent();
therefore any iteration with getgrent will be resetted. - grantpt
-
int grantpt(int fd); + Defines: kill termio getpid open fstat uitodec strlen ioctl write
(../src/termios/pty.c l.49) manpage: grantpt - group_print
-
Defines: write fileno globals strlen getpid kill
(../macros/defgroups.h l.13)
enable print and related functions
This switch enables strlen;
but neither globals nor the mini_buf are used. - group_printf
-
//
Defines: uitodec ultodec atoi uitoHEX getpid kill uitohex write itooct fileno globals strlen
(../macros/defgroups.h l.29)
printf, eprintf, fprintf, itodec, ltodec, itohex, anprintf, sprintf (conversions %d %l %x %ud %ul %ux ), - group_write
-
Defines: write ewrite
(../macros/defgroups.h l.23)
write, and related functions
these functions do not depend on strlen,
or any globals. - htonl
-
static uint32_t htonl(uint32_t i); + Defines: network
(../src/network/htonl.c l.5) manpage: htonl - htons
-
static uint16_t htons(uint16_t i); + Defines: network
(../src/network/htons.c l.3) manpage: htons - inet_aton
-
int inet_aton(const char* s, struct in_addr *addr); + Defines: network
(../src/network/inet_aton.c l.3) manpage: inet_aton - inet_ntoa
-
char* inet_ntoa( struct in_addr in);
Defines: network
(../src/network/inet_ntoa.c l.7) manpage: inet_ntoa
convert a address
This returns a pointer to a string in the globals,
therefore the routine isn’t reentrant.
(whoever thought this might be a good idea..) - initgroups
-
int initgroups(const char* user, gid_t group); + (../src/userdb/initgroups.c l.2) manpage: initgroups
- itobin
-
#define itobin(A,B,…) _itobin(A,B,VARARG(SHIFT(VA_ARGS),0), VARARG(SHIFT(ARG( VA_ARGS )),32) )
Defines:
(../src/conversions/itobin.c l.46)
convert a number to a binary representation.
the conversion assumes a size of 32bits for integers,
negative values are represented as they are stored internally.
( -1 is 11111111111111111111111111111111,
-2 11111111111111111111111111111110, …) - itodec
-
int itodec(int i, char *buf, int prec, char limiter, char pad ); + Defines: uitodec
(../src/conversions/itodec.c l.123) - itooct
-
int itooct(int i, char *buf);
(../src/conversions/itooct.c l.4)
convert int to octal
return the number of chars written. - killpg
-
static int killpg( int pid, int signal ); + (../src/process/killpg.c l.2) manpage: killpg
- locale_dummies
-
(../include/dummies.h l.10)
several dummy definitions,
mostly locale related.
(locales are not the target of minilib,
so define mini_dummies to have code relying on locales
running)
Quite often some code does only checking for locales,
but doesn’t rely on them. - ltodec
-
int ltodec(long i, char *buf, int prec, char limiter ); + Defines: ultodec
(../src/conversions/ltodec.c l.3) - malloc_brk
-
void* malloc_brk(int size);
Defines: sys_brk getbrk
(../src/memory/malloc_brk.c l.16)
allocate via setting the brk
free and realloc can be used normally.
The intention of malloc_brk is for subsequent calls to realloc.
The saved data has not to be copied,
instead realloc just writes the new size and sets
the brk accordingly.
if the break is saved before one or more calls to malloc_brk,
the allocated memory can also be free’d by setting the brk to the saved value
with brk(saved_brk)
free_brk() free’s all memory, which has been allocated with malloc_brk - map_protected
-
void* map_protected(int len);
Defines: mmap mprotect
(../src/memory/map_protected.c l.22)
allocate a buffer, which is surrounded by protected pages.
mprotect(PROT_NONE)
When there is a buffer overflow,
neither the stack, nor other structures can be overwritten.
Instead the overflow (or underflow) touches the next protected page,
what results in a segfault.
Most probably you’d like to catch the segfault signal.
(By installing a segfault signal handler)
The size is always a multiple of the system’s pagesize, 4kB here.
The len of the mapped memory area is rounded up to the next pagesize.
The mapped area can only be free’d by call(s) to unmap_protected,
neither realloc nor free are allowed.
There is one page before, and one page after the mapped area
protected with PROT_NONE, and len rounded up to the next
pagebreak. So this is the overhead.
If an error occures, errno is set (when defined by the switch mini_errno),
and -1 returned, or the negative errno value, when errno isn’t defined. - match
-
int match(char *text, const char *re, text_match *st_match);
Defines:
(../src/match/match.c l.83)
text matching engine
little bit simpler version than match_ext.
Consciusly named text matching, since the inherent logic
is quite different to a regular expression machine.
The engine matches nongreedy straight from left to right,
so backtracking is minimized.
It is a compromise between performance, size
and capabilities.
matches:
-
for every count of any char (nongreedy(!))
+ for 1 or more chars
% for 1 or more chars, and fills in arg 3 (text_match)
? for 1 char
@ matches the beginning of the text or endofline (\n)
→ beginning of a line
# for space, endofline, \t, \n, \f, \r, \v or end of text (0)
$ match end of text
backslash: escape ,?,%,!,,,$ and backslash itself.
! : invert the matching of the next character or character class
[xyz]: character classes, here x,y or z
the characters are matched literally, also \,,?,
,..
it is not possible to match the closing bracket (])
within a character class
+ + % : matches like a, and fills in argument 3,
" will translate into nongreedy matching of any char, however;
the text_match struct, when the pointer is non null.
The matching is nongreedy.
+ + returns: 1 on match, 0 on no match
( RE_MATCH / RE_NOMATCH )
+ if the pointer (argument 3) st_match is nonnull,
the supplied struct text_match will be set to the first matching % location;
if there is no match, text_match.len will be set to 0.
+ The struct is defined as:
typedef struct _text_match { char* pos; int len; } text_match;
+ examples:
"word" matches "words are true" or "true words are rare"
"word*" matches "words are true" and not "true words are rare"
"word" matches none of the above two texts (!)
"words%" extracts with % " are true" and " are rare"
into text_match
"Some\ntext\nwith\nlinebreaks\n\n"
"@%" matches with % "Some"
"@line%#" matches % = "breaks"
"*text\n%" % = "with linebreaks\n\n"
+ + (memo) When the regex ist defined within C/cpp source code,
a backslash has to be defined as double backslash.
+ (note) - be careful when negating a following *, or ?.
somehow - it is logical, but seems to me I overshoot a bit,
and tapped into a logical paradox.
Negating EVERYTHING translates to true.
However, since truth is negated as,… well, there’s a problem.
+ (I’m not kidding here. Just don’t do a regex with ! or !?.,
or you might experience the meaning of full featured.
Maybe I should say, it’s not allowed?)
+ A "!
"%!" will match with % everything but the last char;
" matches with % only the first char.
while "%
!+ basically sets the greedyness of the left * or % higher.
-
- match_ext
-
int match_ext(char *text, const char *re, void(*p_match)(int number, char *pos,int len, void *userdata), int(*p_match_char)(int number, char *match_char, void *userdata), tmatch_ext *st_match, void *userdata);
(../src/match/match_ext.c l.193)
text matching engine
This is somewhere between a fully fledged expression machine,
and a simplicistic solution.
Consciusly named text matching, since the inherent logic
is quite different to a regular expression machine.
The engine matches from left to right,
backtracking is done as less as possible.
Since the matching is nongreedy in general,
many tries can be spared. Opposed to another route,
where most patterns are per default greedy, and therfore
not the first matching next char is seeked for, but the first
solution while matching the most chars.
(I do not want to make this a hard statement, and it
depends onto each pattern. But it is the way, the solution
of the pattern is searched for, in most patterns.)
This shows up in the logic of the patterns, which is more natural to me.
It is a compromise between performance, size
and capabilities.
The logic is different of a "regular" regular expression
machine, but has advantages (and disadvantages).
I’d say, the main advantage is the easiness of adding callbacks,
and defining your own matching/logic within these.
Performance might be better as well overall,
but this depends also on the expressions.
A few nonextensive benchmarks show,
this engine is a bit faster than perl’s regular expression machine,
slower than gnu grep (around factor2), and has the same speed as sed.
This might however vary with each usecase.
In favor of codesize I’m not going to optimize match_ext,
but there would be several possibilities, if you’d need a faster engine.
(Albite I’d like to emphasise, sed (and match_ext), also perl, are quite fast.
About 10 times faster than most expression engines.)
matches:
-
for every count of any char
+ for 1 or more chars
? for 1 char
# for space or end of text (0)
$ match end of text
+ backslash: escape ,?,%,$,!,,,& and backslash itself.
!: invert the matching of the next character or character class
,: separator. e.g. %,1 matches like ?*1.
( without the commata, the 1 would be part of the % match)
+ predefined character classes:
\d - digit
\D - nondigit
\s - space
\S - nonspace
\w - word character ( defined as ascii 32-126,160-255 )
\W - nonword character ( defined as ascii 0-31,127-159 )
+ + [xyz]: character classes, here x,y or z
the characters are matched literally, also \,,?,
,..
it is not possible to match the closing bracket (])
within a character class
+ {nX}: counted match
Match n times X.
For X, all expressions are allowed.
If you need to match a number at the first char of X,
separate X by a commata. E.g. {5,0} matches 5 times 0.
+ %[1]..%[9]: matches like a,
" will translate into nongreedy matching of any char, however;
and calls the callback supplied as 3rd argument (when not null).
the number past the %, e.g. %1, is optional,
p_match will be callen with this number
as first parameter.
When not supplied, p_matched will be callen with
the parameter number set to 0.
+ The matching is nongreedy.
It is possible to rewrite the string to match
from within the p_matched callback.
This will not have an effect onto the current matching,
even if text is e.g. deleted by writing 0’s.
The matched positions are called in reverse order.
(The last matched % in the regex calls p_match first,
the first % in the regex from the left will be callen last)
+ supply 0 for p_matched, when you do not need to extract matches.
This will treat % in the regex like a ,
a following digit (0..9) in the regex is ignored.
if the 5th argument, a pointer to a tmatch_ext struct,
is supplied, it will be filled with the first match.
(counting from left)
+ + &[1] .. &[9]
"match" like a ? and call p_match_char
p_match_char has to return either RE_MATCH, RE_NOMATCH, RE_MATCHEND
or a number of the count of chars, which have been matched.
+ Therefore it is possible to e.g. rule your own
character classes, defined at runtime,
or do further tricks like changing the matched chars,
match several chars, andsoon.
When returning RE_NOMATCH,
it is possible, the p_match and p_match_char callbacks are callen several times,
but with different pos or len parameters.
+ The matching works straight from left to right.
So, a "&*" will call the callback & for the first char.
When returning RE_NOMATCH, the second char will be matched.
Until either RE_MATCH is returned from the callback,
or the last char has been matched.
+ Matching several characters is also posssible from within the callback,
the position within the text will be incremented by that number,
you return from the callback.
+ When returning RE_MATCHEND from the callback,
the whole regular expression is aborted, and returns with matched;
no matter, if there are chars left in the expression.
+ + The difference between % and & is the logic.
% matches nongreedy, and has to check therefore the right side of the star
for its matching.
Possibly this has to be repeated, when following chars do not match.
+ & is matched straight from left to right.
Whatever number you return, the textpointer will be incremented by that value.
However, a & isn’t expanded on it’s own. ( what a % is ).
e.g. "x%x" will match aa in xaax, x&x will match the whole expression
only, when you return 2 from the callback.
+ Performancewise, matching with & is faster,
since the % has on its right side to be matched
with recursing calls of match_ext.
+ When using closures for the callbacks, you will possibly have to
enable an executable stack for the trampoline code
of gcc. Here, gcc complains about that.
For setting this bit, have a look into the ldscripts in the folder
with the same name.
+ supply 0 for p_match_char, when you don’t need it.
This will treat & in the regex like ?,
and match a following digit (0..9) in the text,
a following digit (0..9) in the regex is ignored.
-----
In general, you have to somehow invert the logic of regular expressions
when using match_ext.
e.g. when matching the parameter runlevel=default at the kernel’s
commandline, a working regular expression would be
"runlevel=(\S*)". This could be written here as "runlevel=%".
For matching e.g. numbers, you’d most possibly best of
with writing your own & callback.
+ returns: 1 on match, 0 on no match
( RE_MATCH / RE_NOMATCH )
+ if the pointer (argument 5) st_match is nonnull,
the supplied struct tmatch_ext will be set to the first matching % location;
if there is no match, tmatch_ext.len will be set to 0.
The struct is defined as:
typedef struct _tmatch_ext { char pos; int len; } tmatch_ext;
+ + (memo) When the regex ist defined within C/cpp source code,
a backslash has to be defined as double backslash.
+ (note) - be careful when negating a following , or ?.
somehow - it is logical, but seems to me I overshoot a bit,
tragically hit my own foot, and stumbled into a logical paradox.
+ Negating EVERYTHING translates to true.
However, since truth is negated as well, there’s a problem,
cause it’s now false, but false is true. This is very close
to proving 42 is the answer. What is the escape velocity
in km/s out of the solar system, btw.
+ (I’m not kidding here. Just don’t do a regex with ! or !?..
And, please, do not ask me what is going to happen when the impossible
gets possibilized. I have to point at the according sentences of the BSD license;// there is NO WARRANTY for CONSEQUENTIAL DAMAGE, LOSS OF PROFIT, etc pp.)
+ A "!
"%!" will match with % everything but the last char;
" matches with % only the first char.
while "%
!+ basically sets the greedyness of the left * or % higher.
-
- match_ext2
-
int match_ext2(char text, char *re, void(*p_matched_cb)(int number, char *pos,int len), int(*p_wildcard_cb)(int number, char *match_char),text_match *st_match);
Defines:
(../src/match/match_ext2.c l.306)
text matching engine
WORK IN PROGRESS, please use ext_match
Atm, please nested brackets are featureful.
nesting {} within () seems to work.
Nesting round brackets within {} gives sometimes
trouble, when wildcards are used within the brackets.
I’m leaving this at it is for now.
Possibly I’m going to hardcode an error message for nested brackets,
or nested brackets with wildcards.
This is somewhere between a fully fledged expression machine,
and a simplicistic solution.
Consciusly named text matching, since the inherent logic
is quite different to a regular expression machine;
"natural expressions" might fit better for the name.
The engine matches from left to right,
backtracking is done as less as possible.
Since the matching is nongreedy in general,
many tries can be spared. Opposed to another route,
where most patterns are per default greedy, and therfore
not the first matching next char is seeked for, but the first
solution while matching the most chars.
(I do not want to make this a hard statement, and it
depends onto each pattern. But it is the way, the solution
of the pattern is searched for, in most patterns.)
This shows up in the logic of the patterns, which is more natural to me.
Your mileage might vary.
It is a compromise between performance, size
and capabilities.
The logic is different of a "regular" regular expression
machine, but has advantages (and disadvantages).
I’d say, the main advantage is the easiness of adding callbacks,
and defining your own matching/logic within these.
Performance might be better as well overall,
but this depends on the expressions and usecases as well.
Yet I for myself have to get a grip of the possibilities of this engine.
However, I have the feeling, the logic is much more natural.
With regular regexes you always have to think kind of backwards,
e.g., match "." → match "." (any char) x times.
gets to a simple ""
or, to match all group and user id’s of /etc/passwd,
a regular expression would be: "(\d):(\d*)"
This is here: "(\d):(\d*)*"
The content in the brackets looks the same,
but it’s matched quite different.
The regular expression (the first) matches x times \d, for x>=0.
In the second expressin, the ext_match expression,
the first digit is matched, and then nongreedy any chars, until
the first occurence of :.
It is another logic. Whether it suits you, you have to decide.
The callbacks have shown up to be a mighty tool, while
at the same time having a good performance.
A few nonextensive benchmarks show,
this engine is a bit faster than perl’s regular expression machine,
slower than gnu grep (around factor2), and has the same speed as sed.
This might vary with each usecase, but the callbacks for extracting matches
have some advantage, as well as the strict left to right and nongreedy parsing.
In favor of codesize I’m not going to optimize ext_match,
but there would be several possibilities, if you’d need a faster engine.
(Albite I’d like to emphasise, sed (and ext_match), also perl, are quite fast.
About 5 to 10 times faster than most expression engines.)
matches:
-
for every count of any char
+ for 1 or more chars
? for 1 char
# for space, end of text (\0), linebreak, tab ( \t \n \f \r \v )
@ matches the beginning of the text or endofline (\n)
$ match end of text (\0) or linebreak
+ backslash: escape ,?,%,@,$,!,,,& and backslash itself.
!: invert the matching of the next character or character class
,: separator. e.g. %,1 matches like ?*1.
( without the commata, the 1 would be part of the % match)
+ predefined character classes:
\d - digit
\D - nondigit
\s - space
\S - nonspace
\w - word character ( defined as ascii 32-126,160-255 )
\W - nonword character ( defined as ascii 0-31,127-159 )
\x - hexadecimal digit (0-9,a-f,A-F)
+ + [xyz]: character classes, here x,y or z
the characters are matched literally, also \,,?,
,..
it is not possible to match the closing bracket (])
within a character class
+ {nX}: counted match
Match n times X.
For X, all expressions are allowed.
If you need to match a number at the first char of X,
separate X by a commata. E.g. {5,0} matches 5 times 0.
n can be a number, * or.
1 or more times)
( matches 0 or more,
+ (X): match the subexpression X. atm, no nesting of round () and {} brackets allowed
+ %[1]..%[9]: matches like a,
and calls the callback supplied as 3rd argument (when not null).
the number past the %, e.g. %1, is optional,
p_matched_cb will be callen with this number
as first parameter.
When not supplied, p_matched_cb will be callen with
the parameter number set to 0.
+ The matching is nongreedy.
It is possible to rewrite the string to match
from within the p_matched_cb callback.
This will not have an effect onto the current matching,
even if text is e.g. deleted by writing 0’s.
+ The matched positions are called in reverse order.
+ (The last matched % in the regex calls p_matched_cb first,
the first % in the regex from the left will be callen last)
/ The regex is first matched; when the regex has matched,
the %s are filled/ the callbacks executed.
(x) bracketed patterns are matched the same way.
+ (Not like &, which callbacks are invoked, while matching)
+ supply 0 for p_matched_cb, when you do not need to extract matches.
This will treat % in the regex like a *,
a following digit (0..9) in the regex is ignored.
if the 5th argument, a pointer to a text_match struct,
is supplied, it will be filled with the first match.
(counting from left)
+ + &[1] .. &[9]
"match" like a '? and call p_wildcard_cb
p_wildcard_cb has to return either RE_MATCH, RE_NOMATCH, RE_MATCHEND
or the number of the count of chars, which have been matched.
+ Therefore it is possible to e.g. rule your own
character classes, defined at runtime,
or do further tricks like changing the matched chars,
match several chars, andsoon.
When returning RE_NOMATCH,
it is possible, the p_wildcard_cb callback is callen several times,
but with different pos or len parameters, since p_wildcard_cb is
invoked while matching.
+ The matching works straight from left to right.
So, a "&*" will call the callback & for the first char.
" will translate into nongreedy matching of any char, however;
When returning RE_NOMATCH, the second char will be tried to match.
Until either RE_MATCH is returned from the callback,
or the last char of the text has been tried to match.
+ Matching several characters is also posssible from within the callback,
the position within the text will be incremented by that number,
you return from the callback.
+ When returning RE_MATCHEND from the callback,
the whole expression is aborted, and returns with matched;
no matter, if there are chars left in the expression.
+ + The difference between % and & is the logic.
% matches nongreedy, and has to check therefore the right side of the star
for its matching.
Possibly this has to be repeated, when following chars do not match.
+ & is matched straight from left to right.
Whatever number you return, the textpointer will be incremented by that value.
However, a & isn’t expanded on it’s own. ( what a % is ).
e.g. "x%x" will match aa in xaax, x&x will match the whole expression
only, when you return 2 from the callback.
+ Performancewise, matching with & is faster,
since the % has on its right side to be matched
with recursing calls of ext_match.
+ When using closures for the callbacks, you will possibly have to
enable an executable stack for the trampoline code
of gcc. Here, gcc complains about that.
For setting this bit, please have a look into the ldscripts in the folder
with the same name.
+ supply 0 for p_wildcard_cb, when you don’t need it.
This will treat & in the regex like ?,
and match a following digit (0..9) in the text,
a following digit (0..9) in the regex is ignored.
-----
In general, you have to somehow invert the logic of regular expressions
when using ext_match.
Regular expressions could be regarded as "polish rpn notation",
first the char to be matched, then the count.
This expression machine could be described as "natural expression" machine.
First you define the number, then the chars or expression to be matched.
Furthermore, ,% and + match as less as possible.
You have to think about what needs to follow the wildcards.
+ e.g. when matching the parameter runlevel=default at the kernel’s
commandline, a working regular expression would be
"runlevel=(\S)". This could be written here as "runlevel=%".
For matching e.g. numbers, you’d most possibly best of
with writing your own & callback.
+ returns: 1 on match, 0 on no match
( RE_MATCH / RE_NOMATCH )
+ if the pointer (argument 5) st_match is nonnull,
the supplied struct text_match will be set to the first matching % location;
if there is no match, text_match.len will be set to 0.
The struct is defined as:
typedef struct _text_match { char pos; int len; } text_match;
+ + (memo) When the regex ist defined within C/cpp source code,
a backslash has to be defined as double backslash.
+ (note) - be careful when negating a following , or ?.
somehow - it is logical, but seems to me I overshoot a bit,
tragically hit my own foot, and stumbled into a logical paradox.
+ Negating EVERYTHING translates to true.
However, since truth is negated as well, there’s a problem,
cause it’s now false, but false is true. This is very close
to proving 42 is the answer. What is the escape velocity
in km/s out of the solar system, btw.
+ (I’m not kidding here. Just don’t do a regex with ! or !?..
And, please, do not ask me what is going to happen when the impossible
gets possibilized. I have to point at the according sentences of the BSD license;
there is NO WARRANTY for CONSEQUENTIAL DAMAGE, LOSS OF PROFIT, etc pp.)
+ A "!
"%!" will match with % everything but the last char;
" matches with % only the first char.
while "%
!+ basically sets the greedyness of the left * or % higher.
+ (work in progress here) please use ext_match
return 0 for nomatch, the current textpos ( >0 ) for a match
With the exception of an empty text, matched by e.g. "".
This will return 0, albite the regex formally matches, with 0 chars.
+ (todo)
bracket matching () and {} needs debugging. (test/extmatch2 for testing)
Add a callback for bracket matches, and add a matchlist
(linked list, allocated with malloc_brk)
Trouble: e.g. *:() doesn’t match, albite it should-
better. Now: # matches the end, after a bracket. Like it should
$ doesn’t. But should as well.
change + to greedy matching of any char
for {n,X} let n be * or + as well.
(this would be closer to regular regulars again.?.)
+ + note. About a tokenizer:
matching quoted string is really easy with the callback structure:
just match with &. When a quote is matched, look forward to the next quote,
and return that many chars. Same time, the quoted string is matched.
That’s so easy, it is hard to believe.
When using closures for that, it is same time easy to collect all tokens.
+ It is even easier. just a "("")" is enough.
+ →There is something needed for partial matching. Possibly spare the last *, and return,
as soon the pattern is at it’s end (and not the text?)
Already works this way.
+ Should start to define the language for the init scripts.
Or better, start thinking abut that, but follow my other obligations the next time.
+ Have to think thouroughly about what points would make such a language useful.
The reason to think about that is clear - performance squeezing, faster startup time.
And writing the startup scripts in C is. Well. little bit painful.
However, together with minilib, there is nearly no difference between having a C program compiled
and run, or working with scripts. To not have the overhead of linking the external libraries in,
is of quite some advance.
The only difference, the compiled binaries are "cached".
have just to sort something sensible out for the systematic.
Implement an own loader? possibly easy. Since the loading address is fixed.
This could possibly also be the solution for the yet unclear question of the line between parsing
arguments and calling the main function of the small core tools, andsoon.
..yet I’ve to fiddle out the possibilities (and quirks) of this machine.
seems, this expression language did overpower it’s creator.
+ Bugs (features):
matching e.g. *matches@doesn’t match
potentiates the @ to many possibilities.
One for every linebreak following matches.
-
-
- max_groupmembers
-
#ifndef mini_max_groupmembers
(../include/globaldefs.h l.108)
The maximum number of users,
which are within a group.
used for the allocation of the array gr_mem.
default: 64 - memfrob
-
void* memfrob(void* s, unsigned int len);
(../src/memory/memfrob.c l.4)
frob string; xor every char with 42 - mmap
-
static void* ATTR_OPT("O0") mmap(void* addr, size_t len, int prot, int flags, int fd, off_t off);
(../src/memory/mmap.c l.8) manpage: mmap
mmap wrapper
address length is rounded up to a multiple of pagesize (4096 Bytes here)
for the description, please look up the according manpage
errno is only set, when mini_errno is defined
if not, on error the negative errno value is returned.
(e.g. -22 for "invalid argument") - mremap
-
static void* volatile ATTR_OPT("O0") mremap(void* addr, size_t old_len, size_t new_len, int flags, void* new_addr); + (../include/mremap.h l.4)
- network
-
(../include/network.h l.5)
network definitions - ntohl
-
#define ntohl(i) htonl(i) + (../src/network/ntohl.h l.2) manpage: ntohl
- ntohs
-
#define ntohs(i) htons(i) + Defines: network
(../src/network/macros.h l.2) manpage: ntohs - opendirp
-
static DIR *opendirp(const char *name, DIR *dir); + Defines: sys_brk getbrk close dirbuf 0 open
(../src/directories/opendirp.c l.5) - optimization_fence
-
static void attributenoipa,cold optimization_fence(void*p);
(../include/minilib_global.h l.223)
prevent optimizations.
cast a var to void*, and calling this,
leaves the compiler unknown on what he can strip.
The function attribute noipa means,
the compiler doesn’t know, what the function itself does.
(the function does nothing, but don’t tell that gcc, please..)
therefore, everything used as parameter to this function,
will be calculated, defined, and so on before.
It’s used for the globals,
shich are pushed within _start onto the stack.
since _start itself only provides a global pointer,
and initialitzes some of the globals,
but doesn’t use them again,
this construction is needed.
more funnily, the function will never be called.
It’s past the asm inline syscall to exit.
But again, luckily gcc doesn’t know.
All other options, like having the globals volatile,
setting the optimization flag of _start to 0,
having a volatile asm call with the globals as param, and so on,
have been useless. All after all, seems to me, ai has it’s restrictions.
With less overhead the macro OPTFENCE(…) goes.
There the call to the "ipa" function is jumped over,
via asm inline instructions.
Doesn’t work with clang.
But yet I also didn’t it with clang. - poll
-
static inline int poll(struct pollfd *fds, nfds_t cnt, int timeout); + (../include/poll.h l.25) manpage: poll
- posix_openpt
-
int posix_openpt(int flags); + Defines: termio open
(../src/termios/pty.c l.8) manpage: posix_openpt -
#define print(str) write(STDOUT_FILENO,str,strlen(str))
Defines: write strlen
(../include/prints.h l.53)
write str to stdout. Needs strlen - printfs
-
#define printfs(fmt,…) fprintfs(stdout, fmt, VA_ARGS)
Defines: write fileno strlen
(../include/prints.h l.122)
write fmt and arguments to stdout.
only format %s and %c are recognized - printl
-
#define printl() write(STDOUT_FILENO,"\n",1)
Defines: write
(../include/prints.h l.62)
write a newline to stdout - prints
-
#define prints(…) _mprints(VA_ARGS,0)
Defines: write
(../include/prints.h l.18)
print the string(s) supplied as arg(s) to stdout,
this macro has an variable argument count. - printsl
-
#define printsl(…) _mprints(VA_ARGS,"\n",0)
Defines: write
(../include/prints.h l.42)
print the string(s) supplied as arg(s) and newline to stdout - ptsname
-
char *ptsname(int fd); + Defines: strlen write ioctl termio kill getpid open uitodec
(../src/termios/pty.c l.34) manpage: ptsname - ptsname_r
-
int ptsname_r(int fd, char *buf, size_t len); + Defines: ioctl write strlen uitodec open getpid kill termio
(../src/termios/pty.c l.21) - putenv
-
int putenv( char *string );
Defines: environ ret_errno
(../src/system/putenv.c l.10) manpage: putenv
put a string into the environmental vars
the supplied string’s pointer is put into the environmental array of pointers.
Subsequent changes of the string therefore will change the environment,
and the supplied string may not be deallocated.
Returns:-
0 on success,
-
EINVAL: string was 0, didn’t contain a =, some other error
-
- pwent
-
(../include/pwent.h l.7)
define passwd and group structures - recv
-
int recv(int sockfd, void *buf, size_t len, int flags); + Defines: recvfrom
(../src/network/recv.c l.3) manpage: recv - ret_errno
-
#ifdef mini_errno
(../include/ret_errno.h l.5)
This macro expands to a return, and
(when mini_errno is defined) returns -1 and sets errno,
or returns the negative errno value. - sbrk
-
static void* sbrk(long incr);
Defines: sys_brk
(../src/memory/sbrk.c l.9) manpage: sbrk
Set the new brk, increment/decrement by incr bytes.
return the old brk on success.
conformant sbrk, when mini_errno is defined
if no errno is available,
returns the negative errno value on error - scandir_bufsize
-
(../src/directories/scandir_bufsize.c l.4)
the increment of the buffer of scandir in bytes for memory allocations
(default:4096) - sdbm_hash
-
unsigned long sdbm_hash(const unsigned char *str); + (../src/math/sdbm_hash.c l.3)
- setbrk
-
static int setbrk(long addr);
Defines: sys_brk
(../src/memory/setbrk.c l.6)
set the current brk
wrapper for brk(), with type of brk changed to long - setenv
-
int setenv( const char *name, const char *value, int overwrite );
Defines: 0 ret_errno stpcpy environ strcpy strlen
(../src/system/setenv.c l.15) manpage: setenv
put a string into the environmental vars
UNTESTED (!) TODO
the supplied string’s pointer is put into the environmental array of pointers.
The supplied strings are copied into memory.
If overwrite is zero, an existing environmental variable is not overritten.
If overwrite is 1, the environmental variable is overwritten,
but not(!) freed from memory.
The supplied value is not checked for e.g. an =
Returns:-
0 on success
-
EINVAL on error
-
- seterrno
-
#ifdef mini_errno
(../include/seterrno.h l.3)
set errno, but only when errno is defined. - setgrent
-
void setgrent(); + (../src/userdb/setgrent.c l.3) manpage: setgrent
- setpwent
-
void setpwent(); + (../src/userdb/setpwent.c l.3) manpage: setpwent
- short_errstr
-
const char* short_errstr(int num);
(../include/errstrshort.h l.10)
short error (errno) string.
this adds about 2kB to the compiled binary(!) - shortcolornames
-
(../include/ansicolors.h l.103)
short ansi color names
all colornames, without the praefix "AC_" - snprintf
-
int snprintf( char *buf, size_t size, const char *fmt, … ); + Defines: getpid kill strlen write
(../src/output/snprintf.c l.5) manpage: snprintf - snprintfs
-
int snprintfs( char* buf, int size, char *fmt, …);
Defines: 0
(../src/output/snprintfs.c l.8)
prints formatted and unbuffered output into buf.
only %s and %c are recognized.
snprintfs instead of snprintf can save some bytes.
untested - stpcpy
-
char *stpcpy(char *dest, const char *src);
(../src/string/stpcpy.c l.3) manpage: stpcpy
copy src to dest, return a pointer to the last char +1 ( ending 0 ) - stplcpy
-
char *stplcpy(char *dest, const char *src, int size);
(../src/string/stplcpy.c l.4)
copy src to dest, return a pointer to the last char +1 ( ending 0 )
doesn’t pad dest with 0, when size<src; - stpncpy
-
char *stpncpy(char *dest, const char *src, int size);
(../src/string/stpncpy.c l.6) manpage: stpncpy
copy src to dest, return a pointer to the last char +1 ( ending 0 )
Please note stplcpy (terminology borrowed from freebsd),
which does the same,
but doesn’t pad dest with 0’s. - strcasecmp
-
int strcasecmp(const char*c1,const char*c2); + Defines:
(../src/string/strcasecmp.c l.26) manpage: strcasecmp - strchrnul
-
char *strchrnul(const char *s, int c); + (../src/string/strchrnul.c l.3) manpage: strchrnul
- strlcpy
-
char *strlcpy(char *dest, const char *src, int n);
(../src/string/strlcpy.c l.5) manpage: strlcpy
copy max n chars from src to dest,
when src is longer than dest,
end dest[n-1] with \0. - strncasecmp
-
int strncasecmp(const char*c1,const char*c2,int len); + Defines:
(../src/string/strcasecmp.c l.34) manpage: strncasecmp - strtoimax
-
int strtoimax(const char *c, const char **endp, int base);
(../src/string/strtoimax.c l.4) manpage: strtoimax
conversion - strtok_r
-
char* strtok_r(char *s, const char *delim, char **last); + (../src/string/strtok_r.c l.2) manpage: strtok_r
- strtoll
-
long long int strtoll(const char *c, const char **endp, int base);
Defines: strtol
(../src/string/strtoll.c l.8) manpage: strtoll
conversion
doesn’t check for overflow(!)
For linux x64, long long and long both have 64 bit.
Therefore, strtoll just calls strtol - swap
-
static inline void swap(void* a, void* b,int size);
(../src/sort/swap.c l.5)
swap a with b, with size bytes
swaps integers and longs at once, when size eq sizeof(int/long) - sys_brk
-
static long sys_brk(unsigned long addr);
(../src/memory/sys_brk.c l.4)
the kernel syscall brk. - sys_signame
-
const char* sys_signame[] = ;
(../src/process/signames.h l.3) manpage: sys_signame
abbreviated signal names, according to BSD > 4.2 - tcgetattr
-
int tcgetattr(int fd, struct termios *io); + Defines: ioctl termio
(../src/termios/tcgetattr.c l.12) manpage: tcgetattr - tcsetattr
-
int tcsetattr(int fd, int opt, const struct termios *io); + Defines: termio ioctl
(../src/termios/tcsetattr.c l.12) manpage: tcsetattr - term_width
-
int term_width();
Defines: termio environ
(../src/termios/term_width.c l.7)
get the terminal width
reads the environmental var COLS,
if not present, returns 80.
Doesn’t check for the existence of a terminal. - termio
-
(../include/termio.h l.5)
termios structures and definitions - token_i
-
int token_i( userdb* udb, char **p ); + (../src/userdb/userdb.c l.33)
- token_s
-
char *token_s( userdb *udb, char **p );
(../src/userdb/userdb.c l.19)
tokenizer for the passwd/group files.
used by the group/user pwentry access functions.
performance of subsequent calls could be improved by replacing all : and \n
by 0’s when loading the db file.
it would be possible as well, testing not only single bytes, but
integers of longs at once. However, in most cases, e.g.
for big directories with many small files, in most cases
all files do have the same owner and group. Since the last result to calls
of the access functions is cached,
there wouldn’t be an improvement by optimizing the tokenizing functions.
So I’m leaving this for now, as it is.
And most possibly it would be better to implement bsd’s cached versions
of the user db access functions instead. - uitodec
-
int ATTR_OPT("Os")uitodec(unsigned int i, char *buf, int prec, char limiter, char pad );
(../src/conversions/itodec.c l.9)
convert int to string.
prec: precision, e.g. 4⇒ 0087
pad: 0 (pad with spaces), or the char to pad - ultodec
-
int ultodec(unsigned long ui, char *buf, int prec, char limiter ); + (../src/conversions/ultodec.c l.2)
- unlockpt
-
int unlockpt(int fd); + Defines: termio ioctl
(../src/termios/pty.c l.14) manpage: unlockpt - unmap_protected
-
int unmap_protected(void *p, int len);
Defines: munmap mprotect
(../src/memory/unmap_protected.c l.9)
free an area, allocated before with map_protected
(len must be the same, when at the invocation of map_protected)
returns the value of munmap, when an error occures.
errno is set, when defined.
return 0 on success. - unsetenv
-
int unsetenv( char *name);
Defines: environ ret_errno
(../src/system/unsetenv.c l.10) manpage: unsetenv
remove a string from the environmental vars
The env var is not free’d. (It’s not possible,
since we don’t know whether the string has been allocated
with malloc or has been setup by the system )
Returns:-
0 on success,
-
EINVAL: string was 0, did contain a =, some other error
-
- userdb_open
-
int userdb_open(userdb udb, const char file); + Defines: fstat write globals close
(../src/userdb/userdb_open.c l.3) - verbose_errstr
-
const char* verbose_errstr(int num);
(../include/errstr.h l.10)
verbose error (errno) string.
this adds about 3.5kB to the compiled binary(!) - verbose_errstr2
-
static const char* verbose_errstr2(int num);
(../include/errstr2.h l.11)
verbose error (errno) string.
this adds about 3.5kB to the compiled binary(!)
Trying to shrink that here. - vexec
-
int vexec( const char* path, char* const* argv, char* const* envp );
Defines: vfork wait4 exit execve seterrno
(../src/exec/vexec.c l.6)
execute a path, wait until the executed file exits.
Deviating of system() an absolute pathname is taken.
sets errno on error. - vexec_q
-
int vexec_q( const char* path, char* const* argv, char* const* envp );
Defines: seterrno wait4 vfork execve exit
(../src/exec/vexec_q.c l.6)
execute a path, wait until the executed file exits,
do not write any output of the process. (close stdout)
Deviating of system() an absolute pathname is taken. - vsnprintf
-
int vsnprintf(char buf, size_t size, const char fmt, va_list args );
Defines: getpid kill strlen write
(../src/output/vsnprintf.c l.18) manpage: vsnprintf
the function, translating the fmt of printf.
warning - most possibly you’d like to define besides fprintf, or family,
mini_itodec (%d conversion)
mini_atoi is needed for grouping numbers - warn
-
#define warn( fmt … ) { fprintf(stderr,fmt ); }
Defines: fileno write strlen globals kill getpid
(../src/process/error.h l.33) manpage: warn
print an error message to stderr - where
-
int where(const char *file,char *buf);
Defines: access environ
(../src/exec/where.c l.4)
locate an executable in PATH - writes
-
#define writes(str) write(STDOUT_FILENO,str,sizeof(str))
Defines: write
(../include/prints.h l.83)
write the constant str to stdout. Computes length with sizeof(str) at compile time. - writesl
-
#define writesl(str) write(STDOUT_FILENO,str "\n",sizeof(str)+1)
Defines: write
(../include/prints.h l.93)
write the constant str to stdout, followed by a newline.
Computes length with sizeof(str) at compile time.mini_syscalls
- sys__sysctl
-
syssysctl( struct sysctl_args *args) + (../include/syscalls_x64.h l.316)
- sys_accept
-
sys_accept( int fd, struct sockaddr *upeersockaddr, int *upeeraddrlen) + (../include/syscalls_x64.h l.91)
- sys_accept4
-
sys_accept4( int fd, struct sockaddr *upeer_sockaddr, int *upeer_addrlen, int flags) + (../include/syscalls_x64.h l.552)
- sys_access
-
sys_access( const char *filename, int mode) + (../include/syscalls_x64.h l.47)
- sys_acct
-
sys_acct( const char *name) + (../include/syscalls_x64.h l.330)
- sys_add_key
-
sys_add_key( const char *_type, const char *_description, const void *_payload, size_t plen) + (../include/syscalls_x64.h l.472)
- sys_adjtimex
-
sys_adjtimex( struct timex *txc_p) + (../include/syscalls_x64.h l.322)
- sys_alarm
-
sys_alarm( unsigned int seconds) + (../include/syscalls_x64.h l.79)
- sys_arch_prctl
-
sys_arch_prctl( struct task_struct *task, int code, unsigned long *addr) + (../include/syscalls_x64.h l.320)
- sys_bind
-
sys_bind( int fd, struct sockaddr *umyaddr, int addrlen) + (../include/syscalls_x64.h l.103)
- sys_capget
-
sys_capget( cap_user_header_t header, cap_user_data_t dataptr) + (../include/syscalls_x64.h l.256)
- sys_capset
-
sys_capset( cap_user_header_t header, const cap_user_data_t data) + (../include/syscalls_x64.h l.258)
- sys_chdir
-
sys_chdir( const char *filename) + (../include/syscalls_x64.h l.166)
- sys_chmod
-
sys_chmod( const char *filename, mode_t mode) + (../include/syscalls_x64.h l.186)
- sys_chown
-
sys_chown( const char *filename, uid_t user, gid_t group) + (../include/syscalls_x64.h l.190)
- sys_chroot
-
sys_chroot( const char *filename) + (../include/syscalls_x64.h l.326)
- sys_clock_adjtime
-
sys_clock_adjtime( clockid_t which_clock, struct timex *tx) + (../include/syscalls_x64.h l.586)
- sys_clock_getres
-
sys_clock_getres( const clockid_t which_clock, struct timespec *tp) + (../include/syscalls_x64.h l.436)
- sys_clock_gettime
-
sys_clock_gettime( const clockid_t which_clock, struct timespec *tp) + (../include/syscalls_x64.h l.434)
- sys_clock_nanosleep
-
sys_clock_nanosleep( const clockid_t which_clock, int flags, const struct timespec *rqtp, struct timespec *rmtp) + (../include/syscalls_x64.h l.438)
- sys_clock_settime
-
sys_clock_settime( const clockid_t which_clock, const struct timespec *tp) + (../include/syscalls_x64.h l.432)
- sys_clone
-
sys_clone( unsigned long clone_flags, unsigned long newsp, void *parent_tid, void *child_tid) + (../include/syscalls_x64.h l.117)
- sys_close
-
sys_close( unsigned int fd) + (../include/syscalls_x64.h l.11)
- sys_connect
-
sys_connect( int fd, struct sockaddr *uservaddr, int addrlen) + (../include/syscalls_x64.h l.89)
- sys_creat
-
sys_creat( const char *pathname, int mode) + (../include/syscalls_x64.h l.176)
- sys_delete_module
-
sys_delete_module( const char *name_user, unsigned int flags) + (../include/syscalls_x64.h l.354)
- sys_dup
-
sys_dup( unsigned int fildes) + (../include/syscalls_x64.h l.69)
- sys_dup2
-
sys_dup2( unsigned int oldfd, unsigned int newfd) + (../include/syscalls_x64.h l.71)
- sys_dup3
-
sys_dup3( unsigned int oldfd, unsigned int newfd, int flags) + (../include/syscalls_x64.h l.560)
- sys_epoll_create
-
sys_epoll_create( int size) + (../include/syscalls_x64.h l.408)
- sys_epoll_create1
-
sys_epoll_create1( int flags) + (../include/syscalls_x64.h l.558)
- sys_epoll_ctl
-
sys_epoll_ctl( int epfd, int op, int fd, struct epoll_event *event) + (../include/syscalls_x64.h l.444)
- sys_epoll_pwait
-
sys_epoll_pwait( int epfd, struct epoll_event *events, int maxevents, int timeout, const sigset_t *sigmask, size_t sigsetsize) + (../include/syscalls_x64.h l.538)
- sys_epoll_wait
-
sys_epoll_wait( int epfd, struct epoll_event *events, int maxevents, int timeout) + (../include/syscalls_x64.h l.442)
- sys_eventfd
-
sys_eventfd( unsigned int count) + (../include/syscalls_x64.h l.544)
- sys_eventfd2
-
sys_eventfd2( unsigned int count, int flags) + (../include/syscalls_x64.h l.556)
- sys_execve
-
sys_execve( const char *filename, const char *const argv[], const char *const envp[]) + (../include/syscalls_x64.h l.123)
- sys_exit_group
-
sys_exit_group( int error_code) + (../include/syscalls_x64.h l.440)
- sys_faccessat
-
sys_faccessat( int dfd, const char *filename, int mode) + (../include/syscalls_x64.h l.514)
- sys_fadvise64
-
sys_fadvise64( int fd, loff_t offset, size_t len, int advice) + (../include/syscalls_x64.h l.420)
- sys_fallocate
-
sys_fallocate( long fd, long mode, loff_t offset, loff_t len) + (../include/syscalls_x64.h l.546)
- sys_fanotify_init
-
sys_fanotify_init( unsigned int flags, unsigned int event_f_flags) + (../include/syscalls_x64.h l.576)
- sys_fanotify_mark
-
sys_fanotify_mark( long fanotify_fd, long flags, __u64 mask, long dfd, long pathname) + (../include/syscalls_x64.h l.578)
- sys_fchdir
-
sys_fchdir( unsigned int fd) + (../include/syscalls_x64.h l.168)
- sys_fchmod
-
sys_fchmod( unsigned int fd, mode_t mode) + (../include/syscalls_x64.h l.188)
- sys_fchmodat
-
sys_fchmodat( int dfd, const char *filename, mode_t mode) + (../include/syscalls_x64.h l.512)
- sys_fchown
-
sys_fchown( unsigned int fd, uid_t user, gid_t group) + (../include/syscalls_x64.h l.192)
- sys_fchownat
-
sys_fchownat( int dfd, const char *filename, uid_t user, gid_t group, int flag) + (../include/syscalls_x64.h l.496)
- sys_fcntl
-
sys_fcntl( unsigned int fd, unsigned int cmd, unsigned long arg) + (../include/syscalls_x64.h l.150)
- sys_fdatasync
-
sys_fdatasync( unsigned int fd) + (../include/syscalls_x64.h l.156)
- sys_fgetxattr
-
sys_fgetxattr( int fd, const char *name, void *value, size_t size) + (../include/syscalls_x64.h l.372)
- sys_finit_module
-
sys_finit_module( int fd, const char *uargs, int flags) + (../include/syscalls_x64.h l.602)
- sys_flistxattr
-
sys_flistxattr( int fd, char *list, size_t size) + (../include/syscalls_x64.h l.378)
- sys_flock
-
sys_flock( unsigned int fd, unsigned int cmd) + (../include/syscalls_x64.h l.152)
- sys_fork
-
sysSYSDEF_syscall(_fork,0) + (../include/syscalls_x64.h l.119)
- sys_fremovexattr
-
sys_fremovexattr( int fd, const char *name) + (../include/syscalls_x64.h l.384)
- sys_fsetxattr
-
sys_fsetxattr( int fd, const char *name, const void *value, size_t size, int flags) + (../include/syscalls_x64.h l.366)
- sys_fstat
-
sys_fstat( unsigned int fd, struct stat *statbuf) + (../include/syscalls_x64.h l.15)
- sys_fstatfs
-
sys_fstatfs( unsigned int fd, struct statfs *buf) + (../include/syscalls_x64.h l.280)
- sys_fsync
-
sys_fsync( unsigned int fd) + (../include/syscalls_x64.h l.154)
- sys_ftruncate
-
sys_ftruncate( unsigned int fd, unsigned long length) + (../include/syscalls_x64.h l.160)
- sys_futex
-
sys_futex( u32 *uaddr, int op, u32 val, struct timespec *utime, u32 *uaddr2, u32 val3) + (../include/syscalls_x64.h l.390)
- sys_futimesat
-
sys_futimesat( int dfd, const char *filename, struct timeval *utimes) + (../include/syscalls_x64.h l.498)
- sys_get_mempolicy
-
sys_get_mempolicy( int *policy, unsigned long *nmask, unsigned long maxnode, unsigned long addr, unsigned long flags) + (../include/syscalls_x64.h l.454)
- sys_get_robust_list
-
sys_get_robust_list( int pid, struct robust_list_head **head_ptr, size_t *len_ptr) + (../include/syscalls_x64.h l.524)
- sys_getcpu
-
sys_getcpu( unsigned *cpup, unsigned *nodep, struct getcpu_cache *unused) + (../include/syscalls_x64.h l.594)
- sys_getcwd
-
sys_getcwd( char *buf, unsigned long size) + (../include/syscalls_x64.h l.164)
- sys_getdents
-
sys_getdents( unsigned int fd, struct linux_dirent *dirent, unsigned int count) + (../include/syscalls_x64.h l.162)
- sys_getdents64
-
sys_getdents64( unsigned int fd, struct linux_dirent64 *dirent, unsigned int count) + (../include/syscalls_x64.h l.412)
- sys_getegid
-
sysSYSDEF_syscall(_getegid,0) + (../include/syscalls_x64.h l.222)
- sys_geteuid
-
sysSYSDEF_syscall(_geteuid,0) + (../include/syscalls_x64.h l.220)
- sys_getgid
-
sysSYSDEF_syscall(_getgid,0) + (../include/syscalls_x64.h l.214)
- sys_getgroups
-
sys_getgroups( int gidsetsize, gid_t *grouplist) + (../include/syscalls_x64.h l.236)
- sys_getitimer
-
sys_getitimer( int which, struct itimerval *value) + (../include/syscalls_x64.h l.77)
- sys_getpeername
-
sys_getpeername( int fd, struct sockaddr *usockaddr, int *usockaddr_len) + (../include/syscalls_x64.h l.109)
- sys_getpgid
-
sys_getpgid( pid_t pid) + (../include/syscalls_x64.h l.248)
- sys_getpgrp
-
sysSYSDEF_syscall(_getpgrp,0) + (../include/syscalls_x64.h l.228)
- sys_getpid
-
sysSYSDEF_syscall(_getpid,0) + (../include/syscalls_x64.h l.83)
- sys_getppid
-
sysSYSDEF_syscall(_getppid,0) + (../include/syscalls_x64.h l.226)
- sys_getpriority
-
sys_getpriority( int which, int who) + (../include/syscalls_x64.h l.284)
- sys_getrandom
-
sys_getrandom( char *buf, size_t count, unsigned int flags) + (../include/syscalls_x64.h l.612)
- sys_getresgid
-
sys_getresgid( gid_t *rgid, gid_t *egid, gid_t *sgid) + (../include/syscalls_x64.h l.246)
- sys_getresuid
-
sys_getresuid( uid_t *ruid, uid_t *euid, uid_t *suid) + (../include/syscalls_x64.h l.242)
- sys_getrlimit
-
sys_getrlimit( unsigned int resource, struct rlimit *rlim) + (../include/syscalls_x64.h l.200)
- sys_getrusage
-
sys_getrusage( int who, struct rusage *ru) + (../include/syscalls_x64.h l.202)
- sys_getsid
-
sys_getsid( pid_t pid) + (../include/syscalls_x64.h l.254)
- sys_getsockname
-
sys_getsockname( int fd, struct sockaddr *usockaddr, int *usockaddr_len) + (../include/syscalls_x64.h l.107)
- sys_getsockopt
-
sys_getsockopt( int fd, int level, int optname, char *optval, int *optlen) + (../include/syscalls_x64.h l.115)
- sys_gettid
-
sysSYSDEF_syscall(_gettid,0) + (../include/syscalls_x64.h l.358)
- sys_gettimeofday
-
sys_gettimeofday( struct timeval *tv, struct timezone *tz) + (../include/syscalls_x64.h l.198)
- sys_getuid
-
sysSYSDEF_syscall(_getuid,0) + (../include/syscalls_x64.h l.210)
- sys_getxattr
-
sys_getxattr( const char *pathname, const char *name, void *value, size_t size) + (../include/syscalls_x64.h l.368)
- sys_init_module
-
sys_init_module( void *umod, unsigned long len, const char *uargs) + (../include/syscalls_x64.h l.352)
- sys_inotify_add_watch
-
sys_inotify_add_watch( int fd, const char *pathname, u32 mask) + (../include/syscalls_x64.h l.484)
- sys_inotify_init
-
sysSYSDEF_syscall(_inotify_init,0) + (../include/syscalls_x64.h l.482)
- sys_inotify_init1
-
sys_inotify_init1( int flags) + (../include/syscalls_x64.h l.564)
- sys_inotify_rm_watch
-
sys_inotify_rm_watch( int fd, __s32 wd) + (../include/syscalls_x64.h l.486)
- sys_io_cancel
-
sys_io_cancel( aio_context_t ctx_id, struct iocb *iocb, struct io_event *result) + (../include/syscalls_x64.h l.404)
- sys_io_destroy
-
sys_io_destroy( aio_context_t ctx) + (../include/syscalls_x64.h l.398)
- sys_io_getevents
-
sys_io_getevents( aio_context_t ctx_id, long min_nr, long nr, struct io_event *events) + (../include/syscalls_x64.h l.400)
- sys_io_setup
-
sys_io_setup( unsigned nr_events, aio_context_t *ctxp) + (../include/syscalls_x64.h l.396)
- sys_io_submit
-
sys_io_submit( aio_context_t ctx_id, long nr, struct iocb **iocbpp) + (../include/syscalls_x64.h l.402)
- sys_ioctl
-
sys_ioctl( unsigned int fd, unsigned int cmd, unsigned long arg) + (../include/syscalls_x64.h l.37)
- sys_ioperm
-
sys_ioperm( unsigned long from, unsigned long num, int turn_on) + (../include/syscalls_x64.h l.350)
- sys_iopl
-
sys_iopl( unsigned int level, struct pt_regs *regs) + (../include/syscalls_x64.h l.348)
- sys_ioprio_get
-
sys_ioprio_get( int which, int who) + (../include/syscalls_x64.h l.480)
- sys_ioprio_set
-
sys_ioprio_set( int which, int who, int ioprio) + (../include/syscalls_x64.h l.478)
- sys_kcmp
-
sys_kcmp( pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) + (../include/syscalls_x64.h l.600)
- sys_kexec_file_load
-
sys_kexec_file_load( int kernel_fd, int initrd_fd, unsigned long cmdline_len, const char *cmdline_ptr, unsigned long flags) + (../include/syscalls_x64.h l.616)
- sys_kexec_load
-
sys_kexec_load( unsigned long entry, unsigned long nr_segments, struct kexec_segment *segments, unsigned long flags) + (../include/syscalls_x64.h l.468)
- sys_keyctl
-
sys_keyctl( int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) + (../include/syscalls_x64.h l.476)
- sys_kill
-
sys_kill( pid_t pid, int sig) + (../include/syscalls_x64.h l.130)
- sys_lchown
-
sys_lchown( const char *filename, uid_t user, gid_t group) + (../include/syscalls_x64.h l.194)
- sys_lgetxattr
-
sys_lgetxattr( const char *pathname, const char *name, void *value, size_t size) + (../include/syscalls_x64.h l.370)
- sys_link
-
sys_link( const char *oldname, const char *newname) + (../include/syscalls_x64.h l.178)
- sys_linkat
-
sys_linkat( int oldfd, const char *oldname, int newfd, const char *newname, int flags) + (../include/syscalls_x64.h l.506)
- sys_listen
-
sys_listen( int fd, int backlog) + (../include/syscalls_x64.h l.105)
- sys_listxattr
-
sys_listxattr( const char *pathname, char *list, size_t size) + (../include/syscalls_x64.h l.374)
- sys_llistxattr
-
sys_llistxattr( const char *pathname, char *list, size_t size) + (../include/syscalls_x64.h l.376)
- sys_lookup_dcookie
-
sys_lookup_dcookie( u64 cookie64, long buf, long len) + (../include/syscalls_x64.h l.406)
- sys_lremovexattr
-
sys_lremovexattr( const char *pathname, const char *name) + (../include/syscalls_x64.h l.382)
- sys_lseek
-
sys_lseek( unsigned int fd, off_t offset, unsigned int origin) + (../include/syscalls_x64.h l.21)
- sys_lsetxattr
-
sys_lsetxattr( const char *pathname, const char *name, const void *value, size_t size, int flags) + (../include/syscalls_x64.h l.364)
- sys_lstat
-
sys_lstat( const char *filename, struct stat *statbuf) + (../include/syscalls_x64.h l.17)
- sys_madvise
-
sys_madvise( unsigned long start, size_t len_in, int behavior) + (../include/syscalls_x64.h l.61)
- sys_mbind
-
sys_mbind( unsigned long start, unsigned long len, unsigned long mode, unsigned long *nmask, unsigned long maxnode, unsigned flags) + (../include/syscalls_x64.h l.450)
- sys_memfd_create
-
sys_memfd_create( const char *uname_ptr, unsigned int flags) + (../include/syscalls_x64.h l.614)
- sys_migrate_pages
-
sys_migrate_pages( pid_t pid, unsigned long maxnode, const unsigned long *old_nodes, const unsigned long *new_nodes) + (../include/syscalls_x64.h l.488)
- sys_mincore
-
sys_mincore( unsigned long start, size_t len, unsigned char *vec) + (../include/syscalls_x64.h l.59)
- sys_mkdir
-
sys_mkdir( const char *pathname, int mode) + (../include/syscalls_x64.h l.172)
- sys_mkdirat
-
sys_mkdirat( int dfd, const char *pathname, int mode) + (../include/syscalls_x64.h l.492)
- sys_mknod
-
sys_mknod( const char *filename, umode_t mode, unsigned dev) + (../include/syscalls_x64.h l.272)
- sys_mknodat
-
sys_mknodat( int dfd, const char *filename, int mode, unsigned dev) + (../include/syscalls_x64.h l.494)
- sys_mlock
-
sys_mlock( unsigned long start, size_t len) + (../include/syscalls_x64.h l.302)
- sys_mlockall
-
sys_mlockall( int flags) + (../include/syscalls_x64.h l.306)
- sys_mmap
-
sys_mmap( unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long off) + (../include/syscalls_x64.h l.23)
- sys_modify_ldt
-
sys_modify_ldt( int func, void *ptr, unsigned long bytecount) + (../include/syscalls_x64.h l.312)
- sys_mount
-
sys_mount( char *dev_name, char *dir_name, char *type, unsigned long flags, void *data) + (../include/syscalls_x64.h l.334)
- sys_move_pages
-
sys_move_pages( pid_t pid, unsigned long nr_pages, const void *pages[], const int *nodes, int *status, int flags) + (../include/syscalls_x64.h l.534)
- sys_mprotect
-
sys_mprotect( unsigned long start, size_t len, unsigned long prot) + (../include/syscalls_x64.h l.25)
- sys_mq_getsetattr
-
sys_mq_getsetattr( mqd_t mqdes, const struct mq_attr *u_mqstat, struct mq_attr *u_omqstat) + (../include/syscalls_x64.h l.466)
- sys_mq_notify
-
sys_mq_notify( mqd_t mqdes, const struct sigevent *u_notification) + (../include/syscalls_x64.h l.464)
- sys_mq_open
-
sys_mq_open( const char *u_name, int oflag, mode_t mode, struct mq_attr *u_attr) + (../include/syscalls_x64.h l.456)
- sys_mq_timedreceive
-
sys_mq_timedreceive( mqd_t mqdes, char *u_msg_ptr, size_t msg_len, unsigned int *u_msg_prio, const struct timespec *u_abs_timeout) + (../include/syscalls_x64.h l.462)
- sys_mq_timedsend
-
sys_mq_timedsend( mqd_t mqdes, const char *u_msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *u_abs_timeout) + (../include/syscalls_x64.h l.460)
- sys_mq_unlink
-
sys_mq_unlink( const char *u_name) + (../include/syscalls_x64.h l.458)
- sys_mremap
-
sys_mremap( unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr) + (../include/syscalls_x64.h l.55)
- sys_msgctl
-
sys_msgctl( int msqid, int cmd, struct msqid_ds *buf) + (../include/syscalls_x64.h l.148)
- sys_msgget
-
sys_msgget( key_t key, int msgflg) + (../include/syscalls_x64.h l.142)
- sys_msgrcv
-
sys_msgrcv( int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg) + (../include/syscalls_x64.h l.146)
- sys_msgsnd
-
sys_msgsnd( int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg) + (../include/syscalls_x64.h l.144)
- sys_msync
-
sys_msync( unsigned long start, size_t len, int flags) + (../include/syscalls_x64.h l.57)
- sys_munlock
-
sys_munlock( unsigned long start, size_t len) + (../include/syscalls_x64.h l.304)
- sys_munlockall
-
sysSYSDEF_syscall(_munlockall,0) + (../include/syscalls_x64.h l.308)
- sys_munmap
-
sys_munmap( unsigned long addr, size_t len) + (../include/syscalls_x64.h l.27)
- sys_name_to_handle_at
-
sys_name_to_handle_at( int dfd, const char *name, struct file_handle *handle, int *mnt_id, int flag) + (../include/syscalls_x64.h l.582)
- sys_nanosleep
-
sys_nanosleep( struct timespec *rqtp, struct timespec *rmtp) + (../include/syscalls_x64.h l.75)
- sys_newfstatat
-
sys_newfstatat( int dfd, const char *filename, struct stat *statbuf, int flag) + (../include/syscalls_x64.h l.500)
- sys_open
-
sys_open( const char *filename, int flags, int mode) + (../include/syscalls_x64.h l.9)
- sys_open_by_handle_at
-
sys_open_by_handle_at( int dfd, const char *name, struct file_handle *handle, int *mnt_id, int flags) + (../include/syscalls_x64.h l.584)
- sys_openat
-
sys_openat( int dfd, const char *filename, int flags, int mode) + (../include/syscalls_x64.h l.490)
- sys_pause
-
sysSYSDEF_syscall(_pause,0) + (../include/syscalls_x64.h l.73)
- sys_perf_event_open
-
sys_perf_event_open( struct perf_event_attr *attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags) + (../include/syscalls_x64.h l.572)
- sys_personality
-
sys_personality( unsigned int personality) + (../include/syscalls_x64.h l.274)
- sys_pipe
-
sys_pipe( int *filedes) + (../include/syscalls_x64.h l.49)
- sys_pipe2
-
sys_pipe2( int *filedes, int flags) + (../include/syscalls_x64.h l.562)
- sys_pivot_root
-
sys_pivot_root( const char *new_root, const char *put_old) + (../include/syscalls_x64.h l.314)
- sys_poll
-
sys_poll( struct poll_fd *ufds, unsigned int nfds, long timeout_msecs) + (../include/syscalls_x64.h l.19)
- sys_ppoll
-
sys_ppoll( struct pollfd *ufds, unsigned int nfds, struct timespec *tsp, const sigset_t *sigmask, size_t sigsetsize) + (../include/syscalls_x64.h l.518)
- sys_prctl
-
sys_prctl( int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) + (../include/syscalls_x64.h l.318)
- sys_pread64
-
sys_pread64( unsigned long fd, char *buf, size_t count, loff_t pos) + (../include/syscalls_x64.h l.39)
- sys_preadv
-
sys_preadv( unsigned long fd, const struct iovec *vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h) + (../include/syscalls_x64.h l.566)
- sys_prlimit64
-
sys_prlimit64( pid_t pid, unsigned int resource, const struct rlimit64 *new_rlim, struct rlimit64 *old_rlim) + (../include/syscalls_x64.h l.580)
- sys_process_vm_readv
-
sys_process_vm_readv( pid_t pid, const struct iovec *lvec, unsigned long liovcnt, const struct iovec *rvec, unsigned long riovcnt, unsigned long flags) + (../include/syscalls_x64.h l.596)
- sys_process_vm_writev
-
sys_process_vm_writev( pid_t pid, const struct iovec *lvec, unsigned long liovcnt, const struct iovcc *rvec, unsigned long riovcnt, unsigned long flags) + (../include/syscalls_x64.h l.598)
- sys_pselect6
-
sys_pselect6( int n, fd_set *inp, fd_set *outp, fd_set *exp, struct timespec *tsp, void *sig) + (../include/syscalls_x64.h l.516)
- sys_ptrace
-
sys_ptrace( long request, long pid, unsigned long addr, unsigned long data) + (../include/syscalls_x64.h l.208)
- sys_pwrite64
-
sys_pwrite64( unsigned int fd, const char *buf, size_t count, loff_t pos) + (../include/syscalls_x64.h l.41)
- sys_pwritev
-
sys_pwritev( unsigned long fd, const struct iovec *vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h) + (../include/syscalls_x64.h l.568)
- sys_quotactl
-
sys_quotactl( unsigned int cmd, const char *special, qid_t id, void *addr) + (../include/syscalls_x64.h l.356)
- sys_read
-
sys_read( unsigned int fd, char *buf, size_t count) + (../include/syscalls_x64.h l.5)
- sys_readahead
-
sys_readahead( int fd, loff_t offset, size_t count) + (../include/syscalls_x64.h l.360)
- sys_readlink
-
sys_readlink( const char *path, char *buf, int bufsiz) + (../include/syscalls_x64.h l.184)
- sys_readlinkat
-
sys_readlinkat( int dfd, const char *pathname, char *buf, int bufsiz) + (../include/syscalls_x64.h l.510)
- sys_readv
-
sys_readv( unsigned long fd, const struct iovec *vec, unsigned long vlen) + (../include/syscalls_x64.h l.43)
- sys_reboot
-
sys_reboot( int magic1, int magic2, unsigned int cmd, void *arg) + (../include/syscalls_x64.h l.342)
- sys_recvfrom
-
sys_recvfrom( int fd, void *ubuf, size_t size, unsigned flags, struct sockaddr *addr, int *addr_len) + (../include/syscalls_x64.h l.95)
- sys_recvmmsg
-
sys_recvmmsg( int fd, struct msghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout) + (../include/syscalls_x64.h l.574)
- sys_recvmsg
-
sys_recvmsg( int fd, struct msghdr *msg, unsigned int flags) + (../include/syscalls_x64.h l.99)
- sys_remap_file_pages
-
sys_remap_file_pages( unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long flags) + (../include/syscalls_x64.h l.410)
- sys_removexattr
-
sys_removexattr( const char *pathname, const char *name) + (../include/syscalls_x64.h l.380)
- sys_rename
-
sys_rename( const char *oldname, const char *newname) + (../include/syscalls_x64.h l.170)
- sys_renameat
-
sys_renameat( int oldfd, const char *oldname, int newfd, const char *newname) + (../include/syscalls_x64.h l.504)
- sys_renameat2
-
sys_renameat2( int olddfd, const char *oldname, int newdfd, const char *newname, unsigned int flags) + (../include/syscalls_x64.h l.608)
- sys_request_key
-
sys_request_key( const char *_type, const char *_description, const char *_callout_info, key_serial_t destringid) + (../include/syscalls_x64.h l.474)
- sys_restart_syscall
-
sysSYSDEF_syscall(_restart_syscall,0) + (../include/syscalls_x64.h l.416)
- sys_rmdir
-
sys_rmdir( const char *pathname) + (../include/syscalls_x64.h l.174)
- sys_rt_sigaction
-
sys_rt_sigaction( int sig, const struct sigaction *act, struct sigaction *oact, size_t sigsetsize) + (../include/syscalls_x64.h l.31)
- sys_rt_sigpending
-
sys_rt_sigpending( sigset_t *set, size_t sigsetsize) + (../include/syscalls_x64.h l.260)
- sys_rt_sigprocmask
-
sys_rt_sigprocmask( int how, sigset_t *nset, sigset_t *oset, size_t sigsetsize) + (../include/syscalls_x64.h l.33)
- sys_rt_sigqueueinfo
-
sys_rt_sigqueueinfo( pid_t pid, int sig, siginfo_t *uinfo) + (../include/syscalls_x64.h l.264)
- sys_rt_sigreturn
-
sys_rt_sigreturn( unsigned long __unused) + (../include/syscalls_x64.h l.35)
- sys_rt_sigsuspend
-
sys_rt_sigsuspend( sigset_t *unewset, size_t sigsetsize) + (../include/syscalls_x64.h l.266)
- sys_rt_sigtimedwait
-
sys_rt_sigtimedwait( const sigset_t *uthese, siginfo_t *uinfo, const struct timespec *uts, size_t sigsetsize) + (../include/syscalls_x64.h l.262)
- sys_rt_tgsigqueueinfo
-
sys_rt_tgsigqueueinfo( pid_t tgid, pid_t pid, int sig, siginfo_t *uinfo) + (../include/syscalls_x64.h l.570)
- sys_sched_get_priority_max
-
sys_sched_get_priority_max( int policy) + (../include/syscalls_x64.h l.296)
- sys_sched_get_priority_min
-
sys_sched_get_priority_min( int policy) + (../include/syscalls_x64.h l.298)
- sys_sched_getaffinity
-
sys_sched_getaffinity( pid_t pid, unsigned int len, unsigned long *user_mask_ptr) + (../include/syscalls_x64.h l.394)
- sys_sched_getattr
-
sys_sched_getattr( pid_t pid, struct sched_attr *attr, unsigned int size, unsigned int flags) + (../include/syscalls_x64.h l.606)
- sys_sched_getparam
-
sys_sched_getparam( pid_t pid, struct sched_param *param) + (../include/syscalls_x64.h l.290)
- sys_sched_getscheduler
-
sys_sched_getscheduler( pid_t pid) + (../include/syscalls_x64.h l.294)
- sys_sched_rr_get_interval
-
sys_sched_rr_get_interval( pid_t pid, struct timespec *interval) + (../include/syscalls_x64.h l.300)
- sys_sched_setaffinity
-
sys_sched_setaffinity( pid_t pid, unsigned int len, unsigned long *user_mask_ptr) + (../include/syscalls_x64.h l.392)
- sys_sched_setattr
-
sys_sched_setattr( pid_t pid, struct sched_attr *attr, unsigned int flags) + (../include/syscalls_x64.h l.604)
- sys_sched_setparam
-
sys_sched_setparam( pid_t pid, struct sched_param *param) + (../include/syscalls_x64.h l.288)
- sys_sched_setscheduler
-
sys_sched_setscheduler( pid_t pid, int policy, struct sched_param *param) + (../include/syscalls_x64.h l.292)
- sys_sched_yield
-
sysSYSDEF_syscall(_sched_yield,0) + (../include/syscalls_x64.h l.53)
- sys_seccomp
-
sys_seccomp( unsigned int op, unsigned int flags, const char *uargs) + (../include/syscalls_x64.h l.610)
- sys_select
-
sys_select( int n, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp) + (../include/syscalls_x64.h l.51)
- sys_semctl
-
sys_semctl( int semid, int semnum, int cmd, semun_u arg) + (../include/syscalls_x64.h l.138)
- sys_semget
-
sys_semget( key_t key, int nsems, int semflg) + (../include/syscalls_x64.h l.134)
- sys_semop
-
sys_semop( int semid, struct sembuf *tsops, unsigned nsops) + (../include/syscalls_x64.h l.136)
- sys_semtimedop
-
sys_semtimedop( int semid, struct sembuf *tsops, unsigned nsops, const struct timespec *timeout) + (../include/syscalls_x64.h l.418)
- sys_sendfile
-
sys_sendfile( int out_fd, int in_fd, off_t *offset, size_t count) + (../include/syscalls_x64.h l.85)
- sys_sendmmsg
-
sys_sendmmsg( int fd, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags) + (../include/syscalls_x64.h l.590)
- sys_sendmsg
-
sys_sendmsg( int fd, struct msghdr *msg, unsigned flags) + (../include/syscalls_x64.h l.97)
- sys_sendto
-
sys_sendto( int fd, void *buff, size_t len, unsigned flags, struct sockaddr *addr, int addr_len) + (../include/syscalls_x64.h l.93)
- sys_set_mempolicy
-
sys_set_mempolicy( int mode, unsigned long *nmask, unsigned long maxnode) + (../include/syscalls_x64.h l.452)
- sys_set_robust_list
-
sys_set_robust_list( struct robust_list_head *head, size_t len) + (../include/syscalls_x64.h l.522)
- sys_set_tid_address
-
sys_set_tid_address( int *tidptr) + (../include/syscalls_x64.h l.414)
- sys_setdomainname
-
sys_setdomainname( char *name, int len) + (../include/syscalls_x64.h l.346)
- sys_setfsgid
-
sys_setfsgid( gid_t gid) + (../include/syscalls_x64.h l.252)
- sys_setfsuid
-
sys_setfsuid( uid_t uid) + (../include/syscalls_x64.h l.250)
- sys_setgid
-
sys_setgid( gid_t gid) + (../include/syscalls_x64.h l.218)
- sys_setgroups
-
sys_setgroups( int gidsetsize, gid_t *grouplist) + (../include/syscalls_x64.h l.238)
- sys_sethostname
-
sys_sethostname( char *name, int len) + (../include/syscalls_x64.h l.344)
- sys_setitimer
-
sys_setitimer( int which, struct itimerval *value, struct itimerval *ovalue) + (../include/syscalls_x64.h l.81)
- sys_setns
-
sys_setns( int fd, int nstype) + (../include/syscalls_x64.h l.592)
- sys_setpgid
-
sys_setpgid( pid_t pid, pid_t pgid) + (../include/syscalls_x64.h l.224)
- sys_setpriority
-
sys_setpriority( int which, int who, int niceval) + (../include/syscalls_x64.h l.286)
- sys_setregid
-
sys_setregid( gid_t rgid, gid_t egid) + (../include/syscalls_x64.h l.234)
- sys_setresgid
-
sys_setresgid( gid_t rgid, gid_t egid, gid_t sgid) + (../include/syscalls_x64.h l.244)
- sys_setresuid
-
sys_setresuid( uid_t *ruid, uid_t *euid, uid_t *suid) + (../include/syscalls_x64.h l.240)
- sys_setreuid
-
sys_setreuid( uid_t ruid, uid_t euid) + (../include/syscalls_x64.h l.232)
- sys_setrlimit
-
sys_setrlimit( unsigned int resource, struct rlimit *rlim) + (../include/syscalls_x64.h l.324)
- sys_setsid
-
sysSYSDEF_syscall(_setsid,0) + (../include/syscalls_x64.h l.230)
- sys_setsockopt
-
sys_setsockopt( int fd, int level, int optname, char *optval, int optlen) + (../include/syscalls_x64.h l.113)
- sys_settimeofday
-
sys_settimeofday( struct timeval *tv, struct timezone *tz) + (../include/syscalls_x64.h l.332)
- sys_setuid
-
sys_setuid( uid_t uid) + (../include/syscalls_x64.h l.216)
- sys_setxattr
-
sys_setxattr( const char *pathname, const char *name, const void *value, size_t size, int flags) + (../include/syscalls_x64.h l.362)
- sys_shmat
-
sys_shmat( int shmid, char *shmaddr, int shmflg) + (../include/syscalls_x64.h l.65)
- sys_shmctl
-
sys_shmctl( int shmid, int cmd, struct shmid_ds *buf) + (../include/syscalls_x64.h l.67)
- sys_shmdt
-
sys_shmdt( char *shmaddr) + (../include/syscalls_x64.h l.140)
- sys_shmget
-
sys_shmget( key_t key, size_t size, int shmflg) + (../include/syscalls_x64.h l.63)
- sys_shutdown
-
sys_shutdown( int fd, int how) + (../include/syscalls_x64.h l.101)
- sys_sigaltstack
-
sys_sigaltstack( const stack_t *uss, stack_t *uoss) + (../include/syscalls_x64.h l.268)
- sys_signalfd
-
sys_signalfd( int ufd, sigset_t *user_mask, size_t sizemask) + (../include/syscalls_x64.h l.540)
- sys_signalfd4
-
sys_signalfd4( int ufd, sigset_t *user_mask, size_t sizemask, int flags) + (../include/syscalls_x64.h l.554)
- sys_socket
-
sys_socket( int family, int type, int protocol) + (../include/syscalls_x64.h l.87)
- sys_socketpair
-
sys_socketpair( int family, int type, int protocol, int *usockvec) + (../include/syscalls_x64.h l.111)
- sys_splice
-
sys_splice( int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) + (../include/syscalls_x64.h l.526)
- sys_stat
-
sys_stat( const char *filename, struct stat *statbuf) + (../include/syscalls_x64.h l.13)
- sys_statfs
-
sys_statfs( const char *pathname, struct statfs *buf) + (../include/syscalls_x64.h l.278)
- sys_swapoff
-
sys_swapoff( const char *specialfile) + (../include/syscalls_x64.h l.340)
- sys_swapon
-
sys_swapon( const char *specialfile, int swap_flags) + (../include/syscalls_x64.h l.338)
- sys_symlink
-
sys_symlink( const char *oldname, const char *newname) + (../include/syscalls_x64.h l.182)
- sys_symlinkat
-
sys_symlinkat( const char *oldname, int newfd, const char *newname) + (../include/syscalls_x64.h l.508)
- sys_sync
-
sysSYSDEF_syscall(_sync,0) + (../include/syscalls_x64.h l.328)
- sys_sync_file_range
-
sys_sync_file_range( long fd, loff_t offset, loff_t bytes, long flags) + (../include/syscalls_x64.h l.530)
- sys_syncfs
-
sys_syncfs( int fd) + (../include/syscalls_x64.h l.588)
- sys_sysfs
-
sys_sysfs( int option, unsigned long arg1, unsigned long arg2) + (../include/syscalls_x64.h l.282)
- sys_sysinfo
-
sys_sysinfo( struct sysinfo *info) + (../include/syscalls_x64.h l.204)
- sys_syslog
-
sys_syslog( int type, char *buf, int len) + (../include/syscalls_x64.h l.212)
- sys_tee
-
sys_tee( int fdin, int fdout, size_t len, unsigned int flags) + (../include/syscalls_x64.h l.528)
- sys_tgkill
-
sys_tgkill( pid_t tgid, pid_t pid, int sig) + (../include/syscalls_x64.h l.446)
- sys_time
-
sys_time( time_t *tloc) + (../include/syscalls_x64.h l.388)
- sys_timer_create
-
sys_timer_create( const clockid_t which_clock, struct sigevent *timer_event_spec, timer_t *created_timer_id) + (../include/syscalls_x64.h l.422)
- sys_timer_delete
-
sys_timer_delete( timer_t timer_id) + (../include/syscalls_x64.h l.430)
- sys_timer_getoverrun
-
sys_timer_getoverrun( timer_t timer_id) + (../include/syscalls_x64.h l.428)
- sys_timer_gettime
-
sys_timer_gettime( timer_t timer_id, struct itimerspec *setting) + (../include/syscalls_x64.h l.426)
- sys_timer_settime
-
sys_timer_settime( timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting) + (../include/syscalls_x64.h l.424)
- sys_timerfd_create
-
sys_timerfd_create( int clockid, int flags) + (../include/syscalls_x64.h l.542)
- sys_timerfd_gettime
-
sys_timerfd_gettime( int ufd, struct itimerspec *otmr) + (../include/syscalls_x64.h l.550)
- sys_timerfd_settime
-
sys_timerfd_settime( int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr) + (../include/syscalls_x64.h l.548)
- sys_times
-
sys_times( struct sysinfo *info) + (../include/syscalls_x64.h l.206)
- sys_tkill
-
sys_tkill( pid_t pid, int sig) + (../include/syscalls_x64.h l.386)
- sys_truncate
-
sys_truncate( const char *path, long length) + (../include/syscalls_x64.h l.158)
- sys_umask
-
sys_umask( int mask) + (../include/syscalls_x64.h l.196)
- sys_umount2
-
sys_umount2( const char *target, int flags) + (../include/syscalls_x64.h l.336)
- sys_uname
-
sys_uname( struct old_utsname *name) + (../include/syscalls_x64.h l.132)
- sys_unlink
-
sys_unlink( const char *pathname) + (../include/syscalls_x64.h l.180)
- sys_unlinkat
-
sys_unlinkat( int dfd, const char *pathname, int flag) + (../include/syscalls_x64.h l.502)
- sys_unshare
-
sys_unshare( unsigned long unshare_flags) + (../include/syscalls_x64.h l.520)
- sys_ustat
-
sys_ustat( unsigned dev, struct ustat *ubuf) + (../include/syscalls_x64.h l.276)
- sys_utime
-
sys_utime( char *filename, struct utimbuf *times) + (../include/syscalls_x64.h l.270)
- sys_utimensat
-
sys_utimensat( int dfd, const char *filename, struct timespec *utimes, int flags) + (../include/syscalls_x64.h l.536)
- sys_utimes
-
sys_utimes( char *filename, struct timeval *utimes) + (../include/syscalls_x64.h l.448)
- sys_vfork
-
sysSYSDEF_syscall(_vfork,0) + (../include/syscalls_x64.h l.121)
- sys_vhangup
-
sysSYSDEF_syscall(_vhangup,0) + (../include/syscalls_x64.h l.310)
- sys_vmsplice
-
sys_vmsplice( int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags) + (../include/syscalls_x64.h l.532)
- sys_wait4
-
sys_wait4( pid_t upid, int *stat_addr, int options, struct rusage *ru) + (../include/syscalls_x64.h l.128)
- sys_waitid
-
sys_waitid( int which, pid_t upid, struct siginfo *infop, int options, struct rusage *ru) + (../include/syscalls_x64.h l.470)
- sys_write
-
sys_write( unsigned int fd, const char *buf, size_t count) + (../include/syscalls_x64.h l.7)
- sys_writev
-
sys_writev( unsigned long fd, const struct iovec *vec, unsigned long vlen) + (../include/syscalls_x64.h l.45)
signal.h
- raise
-
static inline int raise(int signr); + Defines: getpid kill
(../src/process/sigaction.c l.145) manpage: raise - sigaction
-
static int volatile sigaction(int sig, const struct sigaction *act, struct sigaction *oact); + Defines: rt_sigaction memcpy
(../src/process/sigaction.c l.117) manpage: sigaction - sigaddset
-
int sigaddset(sigset_t *set, int sig); + (../src/process/sigaction.c l.34) manpage: sigaddset
- sigdelset
-
int sigdelset(sigset_t *set, int sig); + (../src/process/sigaction.c l.68) manpage: sigdelset
- sigemptyset
-
static int sigemptyset(sigset_t *set); + (../src/process/sigaction.c l.7) manpage: sigemptyset
- sigfillset
-
static int sigfillset(sigset_t *set); + (../src/process/sigaction.c l.20) manpage: sigfillset
- sigismember
-
int sigismember(sigset_t *set, int sig); + (../src/process/sigaction.c l.85) manpage: sigismember
- signal
-
sighandler_t signal(int sig, sighandler_t func ); + Defines: rt_sigaction write memcpy
(../src/process/signal.c l.5) manpage: signal - sigprocmask
-
int sigprocmask(int how, const sigset_t *set, sigset_t *oldset); + Defines: rt_sigprocmask
(../src/process/sigaction.c l.61) manpage: sigprocmask - sigsuspend
-
static int sigsuspend( const sigset_t *mask ); + Defines: rt_sigsuspend
(../src/process/sigaction.c l.53) manpage: sigsuspendstdio.h
- _fopen
-
FILE _fopen(int fd, const char filename, const char* mode, FILE *f);
Defines: close fileno open
(../src/streams/_fopen.c l.12)
modes implemented: r, r+, w, w+, a, a+ - _itohex
-
int _itohex(int i,char* buf,int padding, int capitals); + (../src/conversions/itohex.c l.6)
- clearerr
-
static inline void clearerr(FILE *f); + (../include/mini_fstream.h l.189) manpage: clearerr
- clearerror
-
static inline void clearerror(FILE *f); + (../include/mini_fstream.h l.194)
- fclose
-
static inline int attributealways_inline fclose( FILE* f ); + Defines: close
(../include/mini_fstream.h l.66) manpage: fclose - fdopen
-
FILE fdopen(int fd, const char mode);
Defines: open fileno close
(../src/streams/fdopen.c l.6) manpage: fdopen
modes implemented: r, r+, w, w+, a, a+ - feof
-
static inline int feof(FILE *f); + (../include/mini_fstream.h l.175) manpage: feof
- ferror
-
static inline int ferror(FILE *f); + (../include/mini_fstream.h l.182) manpage: ferror
- fflush
-
static inline int attributealways_inline fflush( FILE *F );
(../include/mini_fstream.h l.28) manpage: fflush
This does nothing, since minilib doesn’t provide buffered streams yet.In order to sync data to disc, please use fsync - fgetc
-
static inline int fgetc(FILE *F); + Defines: fileno read
(../src/streams/fgetc.c l.5) manpage: fgetc - fgetpos
-
static inline void fgetpos(FILE *f, long *pos ); + Defines: lseek
(../include/mini_fstream.h l.117) manpage: fgetpos - fgets
-
char* fgets(char buf, int size, FILE F); + Defines: read fileno
(../src/streams/fgets.c l.4) manpage: fgets - fileno
-
static int fileno( FILE *f );
(../include/mini_fstream.h l.56) manpage: fileno
Return the fd nummber of stdin,-out,-err. - fopen
-
FILE fopen(const char filename, const char* mode);
Defines: fileno open close
(../src/streams/fopen.c l.8) manpage: fopen
modes implemented: r, r+, w, w+, a, a+ - fprint
-
#define fprint(…) fprintf(VA_ARGS) + Defines: getpid kill write fileno globals strlen
(../include/mini_fstream.h l.84) - fprintf
-
#define fprintf(stream,…) write(fileno(stream),mlgl→mbuf,snprintf(mlgl→mbuf,mlgl→mbufsize,VA_ARGS))
Defines: kill getpid strlen globals fileno write
(../src/output/fprintf.c l.32) manpage: fprintf
fprintf, formatted output
conversions implemented:
%d: signed int (mini_itodec)
%u: unsigned int (mini_uitodec)
%f: double (max precision 8 digits, highest possible number: 2^31 (mini_dtodec)
%l (modify a following d,u to long) (mini_ltodec,mini_ultodec)
%s: string
%c: char
binary and hex output print the numbers,
as they are internally stored(!).
Negative numbers are represented with the first sign bit set.
(e.g. -1 = 0xFFFFFFFF at x64)
%b : binary output (mini_itobin)
%o : octal output (mini_itooct)
%x/X : hex output (small/big capitals) (mini_itohex,mini_itoHEX
%(: grouping (mini_atoi)
warning - most possibly you’d like to define besides fprintf, or family,
mini_itodec (%d conversion)
For squeezing a few more bytes, and saving some checking;
writes(constant string) and print (variable string),
prints (formatted output of one or several strings) are provided.
- fputc
-
static inline int volatile fputc(int c, FILE* F); + Defines: write fileno
(../include/fputc.h l.9) manpage: fputc - fputs
-
static inline int volatile fputs(const char *c, FILE *F); + Defines: strlen fileno write
(../include/fputs.h l.18) manpage: fputs - fread
-
static inline size_t fread(void *ptr, size_t size, size_t nmemb, FILE *f); + Defines: read
(../include/mini_fstream.h l.152) manpage: fread - freopen
-
FILE freopen(const char filename, const char* mode, FILE *F);
Defines: open fileno close
(../src/streams/freopen.c l.7) manpage: freopen
modes implemented: r, r+, w, w+, a, a+ - fseek
-
static inline int fseek(FILE *f, long offset, int whence ); + Defines: lseek
(../include/mini_fstream.h l.134) manpage: fseek - fsetpos
-
static inline int fsetpos(FILE *f, int pos ); + Defines: lseek
(../include/mini_fstream.h l.123) manpage: fsetpos - ftell
-
static inline long ftell(FILE *f); + Defines: lseek
(../include/mini_fstream.h l.111) manpage: ftell - fwrite
-
static inline size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *f); + Defines: write
(../include/mini_fstream.h l.95) manpage: fwrite - getc
-
#define getc(F) fgetc(F) + Defines: read fileno
(../include/fgetc.h l.8) manpage: getc - getchar
-
#define getchar() fgetc(0) + Defines: fileno read
(../include/fgetc.h l.11) manpage: getchar - gets
-
#define gets(F) fgets(F,0xfffffff,stdin) + Defines: fileno read
(../src/streams/gets.c l.3) manpage: gets - itoHEX
-
int itoHEX(int i,char* buf,int padding);
Defines:
(../src/conversions/itohex.c l.65)
convert a number to hexadecimal representation with big capitals.
the conversion assumes a size of 32bits for integers,
negative values are represented as they are stored internally.
( -1 is 0xFFFFFFFF, -2 0xFFFFFFFE, … ) - itohex
-
int itohex(int i,char* buf,int padding);
Defines:
(../src/conversions/itohex.c l.53)
convert a number to hexadecimal representation.
the conversion assumes a size of 32bits for integers,
negative values are represented as they are stored internally.
( -1 is 0xffffffff, -2 0xfffffffe, … ) - perror
-
void perror(const char *msg); + Defines: errno strlen write strerror fileno
(../src/output/perror.c l.4) manpage: perror - printf
-
#define printf(…) fprintf(stdout,VA_ARGS) + Defines: strlen globals fileno write kill getpid
(../include/mini_fstream.h l.80) manpage: printf - putc
-
#define putc(c,stream) fputc(c,stream) + Defines: write fileno
(../include/fputc.h l.18) manpage: putc - putchar
-
#define putchar(c) fputc(c,stdout) + Defines: fileno write
(../include/fputc.h l.15) manpage: putchar - puts
-
#define puts(msg) ( print(msg) + printl() )
Defines: kill getpid fileno write strlen globals
(../include/prints.h l.72) manpage: puts
write msg to stdout, append a newline. Needs strlen. - rewind
-
static inline void rewind( FILE *f ); + Defines: lseek
(../include/mini_fstream.h l.143) manpage: rewind - setbuf
-
static void setbuf(FILE *stream, char *buf);
(../include/mini_fstream.h l.202) manpage: setbuf
dummy function.
There is no buffering implemented for the streams yet. - setvbuf
-
static int setvbuf(FILE *stream, char *buf, int mode, size_t size);
(../include/mini_fstream.h l.207) manpage: setvbuf
dummy function - sprintf
-
#define sprintf(str,…) snprintf( str, mini_buf, VA_ARGS)
Defines: getpid kill strlen write
(../src/output/sprintf.c l.9) manpage: sprintf
I’m really uncertain about the size arg here, amongst others
these are just misdefined functions, inhaerent insecure. :/
If possible, do not use sprintf. Use snprintf instead. - ungetc
-
static int ungetc(int c, FILE *F);
(../src/streams/ungetc.c l.5) manpage: ungetc
pushes one char back to the stream.
Overwrites a previously pushed char
(conforming to the posix spec) - vfprintf
-
#define vfprintf(…) fprintf(VA_ARGS) + Defines: kill getpid fileno write strlen globals
(../include/mini_fstream.h l.89) manpage: vfprintf - vsprintf
-
int vsprintf( char *buf, const char *fmt, … );
Defines: 0
(../src/output/vsprintf.c l.10) manpage: vsprintf
write fmt and arguments into buf
calls vsnprintf,
the size is limited to 4096 by default and assumes
a buf len of 4096.stdlib.h
- abort
-
void abort(); + Defines: getpid kill rt_sigaction write memcpy
(../src/process/abort.c l.3) manpage: abort - abs
-
static int abs(int i); + (../include/math.h l.25) manpage: abs
- atexit
-
static int atexit( functionp* func );
Defines: globals
(../src/process/atexit.c l.7) manpage: atexit
register functions, which are callen on exit in reverse order
the switch mini_atexit takes a optional number,
which defines the maximum numbers of functions to be registered.
(defaults to 8) - atoi
-
int atoi(const char *c); + (../src/conversions/atoi.c l.3) manpage: atoi
- atol
-
long atol(const char *c); + (../src/conversions/atol.c l.3) manpage: atol
- bsearch
-
void* bsearch(const void *key, const void *base0, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
(../src/sort/bsearch.c l.55) manpage: bsearch
search for an element
code is copied from netbsd - calloc
-
void* calloc(int nmemb, int size); + (../src/memory/calloc.c l.2) manpage: calloc
- div
-
static div_t div(int numerator, int denominator); + (../include/math.h l.8) manpage: div
- free
-
void free(void *p); + Defines: sys_brk getbrk
(../src/memory/malloc.c l.168) manpage: free - getenv
-
char* getenv(const char* name); + Defines: environ
(../src/system/getenv.c l.5) manpage: getenv - labs
-
static long int labs(long int i); + (../include/math.h l.30) manpage: labs
- ldiv
-
static ldiv_t ldiv(long int numerator, long int denominator); + (../include/math.h l.16) manpage: ldiv
- malloc
-
void* malloc(int size);
Defines: 0
(../src/memory/malloc.c l.142) manpage: malloc
0
switch mini_malloc_minibuf
(Use the global minibuf for "allocations".
Advantage: tiny code, fast, located either in the bss or data segment,
or past the stack(might be fastest).
Disadvantage: Possible to overwrite environmental vsariables when located
at the stack via overflow.
No dynamic allocations, the minibuf has a fixed size.
Here we go.. with the .. well.
Fastes and smallest malloc/free combi ever.
Not the smartest.
Since it isn’t exactly a memory allocation,
instead it uses the minilib buf.
Which is allocated by the kernel, and located
either in the bss section, or is allocated on the stack.
(option "globals_on_stack")
When allocated at the stack, the stack is first expanded
within startup_c.c, and the return address of startup_c
discarded. (Jump to exit)
Therefore an overflow of the globals would result in a segfault.
For debugging and analization of mallocs and free’s, there’s
the option analyzemalloc; which dumps all malloc’s and free’s to stderr.
Format: Address - size)
This is basically a linked list,
optimized for fast access, allocation of new elements,
and small memory overhead.
Albite the list structure might be hard to recognize.
It is not the right malloc, if you expect
many de- or reallocations.
And it obviously is not the right choose, when
expecting medium to big sized allocations. (> 1 page, here 4kB, as medium sized)
Here we use mbuf from top to bottom as stack.
64 Bytes are left at the bottom as reserve.
Possibly we’d like to complain
about the lack of memory, before we exit.
ATM, the free is really lazy.
It free’s memory, but a real free is only commited,
when all memory below a freed area is also freed.
Since the target of minilib atm are tiny tools,
this might be ok.
;) but, as I told before -
probably you should look out for a proper malloc implementation.
It depends on your needs.
I’m not sure yet,
whether another implementation of free would be useful at all.
Overall, I’d really prefer keeping minilib tiny.
Reusing sparse freed memory areas also leads
to a whole bunch of complications.
cache misses, searching complexity,
storage overhead, potentially page faults,
just to name a few.
I’m not sure whether it’s worth it.
And the existing malloc implementations
out there are countless.
;) It’s sometimes smarter to stay special,
albite in this case this means the opposite.
/misc
The memory layout looks like this:
mlgl→ibuf and mlgl→mbuf do point to the same address range.
mlgl→ibuf is provided for alignment and faster access to the int values.
flag prev free is the first bit in size. (0x8000, eq 1000 0000 0000 0000 binary when free),
(mbufsize)
```
size data size mini_buf size
8008dataxxxx0004data8000|
----========----====----|
also, when free space is in between two areas
8004data8008 free 0004data8000|
----====----__----====----|
```
the free space is only freed,
when all areas below (left) have been free’d as well.
Memory is allocated from right to left,
meaning from top to down. - qsort
-
void qsort(void *base, size_t nel, size_t width, int (*comp)(const void *, const void *));
Defines: swap
(../src/sort/qsort.c l.35) manpage: qsort
(quick) shell sort routine
following the tradition, this isn’t exactly a quicksort algorithm,
albite named quicksort.
It is a shell sort implementation, originally done by Ray Gardner, 5/90;
which in turn I did find within musl. - rand
-
unsigned int rand(); + (../src/math/rand.c l.7) manpage: rand
- realloc
-
void* realloc(void *p, int size); + Defines: 0 getbrk sys_brk
(../src/memory/malloc.c l.240) manpage: realloc - srand
-
void srand( unsigned int i ); + (../src/math/srand.c l.4) manpage: srand
- strtol
-
long int strtol(const char *c, const char **endp, int base);
(../src/string/strtol.c l.4) manpage: strtol
conversion - system
-
int system( const char* command ); + Defines: write environ vfork wait4 execve
(../src/exec/system.c l.4) manpage: systemstring.h
- _strcmp
-
int _strcmp(const char *s1, const char *s2, int n); + (../src/string/strcmp.c l.10)
- memchr
-
void* memchr(const void *s, int c, unsigned int n); + (../src/memory/memchr.c l.2) manpage: memchr
- memcmp
-
int memcmp(const void* c1,const void* c2,int len); + Defines: 0
(../src/memory/memcmp.c l.3) manpage: memcmp - memcpy
-
void* memcpy( void*d, const void *s, int n ); + (../src/memory/memcpy.c l.4) manpage: memcpy
- memmove
-
void* memmove(void *dest, const void *src, int n); + (../src/memory/memmove.c l.3) manpage: memmove
- memset
-
void *memset( void *s, int c, int n); + (../src/memory/memset.c l.3) manpage: memset
- strcat
-
char *strcat(char *dest, const char *src ); + Defines: strlen
(../src/string/strcat.c l.5) manpage: strcat - strchr
-
char *strchr(const char *s, int c); + Defines: strchrnul
(../src/string/strchr.c l.6) manpage: strchr - strcmp
-
int strcmp(const char*c1,const char*c2); + Defines:
(../src/string/strcmp.c l.36) manpage: strcmp - strcpy
-
char *strcpy(char *dest, const char *src); + (../src/string/strcpy.c l.3) manpage: strcpy
- strcspn
-
int strcspn(const char *s1, const char *s2);
(../src/string/strcspn.c l.6) manpage: strcspn
look for the first place in s1,
containing one of the chars of s2.
Optimizes a bit (+16Bytes code),
when OPTIMIZE is defined - strdup
-
char *strdup(const char *source); + Defines: strcpy strlen 0
(../src/string/strdup.c l.7) manpage: strdup - strerror
-
static char* strerror( int errnum ); + (../src/string/strerror.c l.7) manpage: strerror
- strlen
-
int strlen(const char*str);
(../src/string/strlen.c l.6) manpage: strlen
return len of str.
if str points to 0, return 0 - strncat
-
char* strncat( char* dst, const char* src, unsigned int n); + (../src/string/strncat.c l.2) manpage: strncat
- strncmp
-
int strncmp(const char*c1,const char*c2,int len); + Defines:
(../src/string/strcmp.c l.44) manpage: strncmp - strncpy
-
char *strncpy(char *dest, const char *src, int n);
(../src/string/strncpy.c l.7) manpage: strncpy
copy max n chars from src to dest,
write 0’s up to src[n] when len of dest < n
Please note strlcpy (borrowed from freebsd),
which does the same,
but doesn’t pad dest with 0’s. - strndup
-
char *strndup(const char *source, int maxlen); + Defines: strlen stplcpy 0
(../src/string/strndup.c l.5) manpage: strndup - strnlen
-
int strnlen(const char*str, int max);
(../src/string/strnlen.c l.8) manpage: strnlen
return len of str.
if str points to 0, return 0
if no 0 is within max chars of str,
return max - strpbrk
-
char* strpbrk(const char* s, const char* charset); + (../src/string/strpbrk.c l.2) manpage: strpbrk
- strrchr
-
char *strrchr(const char *s, int c); + Defines: strchrnul
(../src/string/strrchr.c l.4) manpage: strrchr - strspn
-
int strspn(const char *s1, const char *s2); + (../src/string/strspn.c l.2) manpage: strspn
- strstr
-
char* strstr(const char *big, const char *little); + (../src/string/strstr.c l.3) manpage: strstr
- strtok
-
char* strtok(char *s, const char *delim); + Defines: strtok_r
(../src/string/strtok.c l.3) manpage: strtoksys/wait.h
- wait
-
pid_t wait(int *wstatus); + Defines: wait4
(../src/process/wait.c l.8) manpage: wait - waitpid
-
pid_t waitpid(pid_t pid, int *wstatus, int options); + Defines: wait4
(../src/process/wait.c l.16) manpage: waitpidtime.h
- time
-
time(unsigned int *a1 ) + (../include/syscall_stubs.h l.277) manpage: time
unistd.h
- access
-
access( const char *filename, int mode) + (../include/syscall_stubs.h l.177) manpage: access
- chdir
-
chdir(const char* path) + (../include/syscall_stubs.h l.114) manpage: chdir
- chown
-
chown( const char *filename, uid_t user, gid_t group) + (../include/syscall_stubs.h l.202) manpage: chown
- chroot
-
chroot( const char *filename) + (../include/syscall_stubs.h l.155) manpage: chroot
- close
-
close( int fd ) + (../include/syscall_stubs.h l.102) manpage: close
- dup
-
dup(int fd) + (../include/syscall_stubs.h l.119) manpage: dup
- dup2
-
dup2(int oldfd, int newfd) + (../include/syscall_stubs.h l.120) manpage: dup2
- execl
-
static int execl(const char pathname, const char arg0,… ); + Defines: execve environ
(../src/exec/execl.c l.6) manpage: execl - execv
-
static inline int execv(const char *pathname, char *const argv[]); + Defines: execve environ
(../src/exec/_execv.c l.4) manpage: execv - execve
-
execve( const char filename, char const* argv, char* const* envp) + (../include/syscall_stubs.h l.134) manpage: execve
- execvp
-
static inline int execvp(const char *file, char *const argv[]); + Defines: environ access execve
(../src/exec/_execvp.c l.4) manpage: execvp - execvpe
-
static int execvpe(const char *file, char *const argv[], char *const envp[]);
Defines: environ access execve
(../src/exec/execvp.c l.11)
When invoked with a filename, starting with "." or "/",
interprets this as absolute path. (calls execve with the pathname)
Looks for file in the PATH environment, othwerise. - fork
-
DEF_syscall(fork,0) + (../include/syscall_stubs.h l.138) manpage: fork
- fsync
-
fsync(int a1 ) + (../include/lseek.h l.21) manpage: fsync
- ftruncate
-
ftruncate(unsigned int a1, unsigned int a2 ) + (../include/lseek.h l.20) manpage: ftruncate
- getegid
-
DEF_syscall(getegid,0) + (../include/syscall_stubs.h l.215) manpage: getegid
- geteuid
-
DEF_syscall(geteuid,0) + (../include/syscall_stubs.h l.213) manpage: geteuid
- getgid
-
DEF_syscall(getgid,0) + (../include/syscall_stubs.h l.206) manpage: getgid
- getgroups
-
int getgroups(int maxgroups, int *list);
Defines: getuid token_s open passwdfile_open pwent token_i setpwent setgrent userdb grent mmap write
(../src/userdb/getgroups.c l.8) manpage: getgroups
get the groups of the calling process
does not necessarily contain the primary group,
which is given in the passwd entry.
This function calls internally setgrent() and getgrent();
therefore any iteration with getgrent will be resetted. - gethostname
-
static int gethostname(char *name,int len);
Defines: uname network
(../src/network/gethostname.c l.4) manpage: gethostname
gethostname - getpgrp
-
DEF_syscall(getpgrp,0) + (../include/syscall_stubs.h l.207) manpage: getpgrp
- getpid
-
DEF_syscall(getpid,0 ) + (../include/syscall_stubs.h l.159) manpage: getpid
- getuid
-
DEF_syscall(getuid,0) + (../include/syscall_stubs.h l.208) manpage: getuid
- isatty
-
int isatty(int fd); + Defines: termio ioctl
(../src/termios/isatty.c l.5) manpage: isatty - link
-
link( const char *oldname, const char *newname) + (../include/syscall_stubs.h l.125) manpage: link
- lseek
-
lseek(unsigned int a1, int a2, int a3 ) + (../include/lseek.h l.18) manpage: lseek
- mkdir
-
mkdir( const char *pathname, int mode) + (../include/syscall_stubs.h l.174) manpage: mkdir
- open
-
int volatile open( const char *s, int flags, … );
(../src/file/open.c l.18) manpage: open
open or create a file.
warning: when using the flag O_CREAT,
file permission flags have to be given
as third argument. Otherwise file permission
flags will be random. (I still do not know, what
the flag showing up as "-T" means..) - pipe
-
pipe( int *filedes) + (../include/syscall_stubs.h l.256) manpage: pipe
- read
-
read( int fd, void *buf, int len ) + (../include/syscall_stubs.h l.103) manpage: read
- rename
-
rename( const char* oldpath, const char* newpath ) + (../include/syscall_stubs.h l.108) manpage: rename
- rmdir
-
rmdir( const char *pathname) + (../include/syscall_stubs.h l.175) manpage: rmdir
- select
-
static int volatile ATTR_OPT("O0") select(int fd, volatile fd_set* readfd, volatile fd_set *writefd, volatile fd_set *exceptfd, volatile struct timeval *wait); + (../include/select.h l.16) manpage: select
- setgid
-
setgid( gid_t gid) + (../include/syscall_stubs.h l.161) manpage: setgid
- setpgid
-
setpgid( pid_t pid, pid_t pgid) + (../include/syscall_stubs.h l.205) manpage: setpgid
- setsid
-
DEF_syscall(setsid,0 ) + (../include/syscall_stubs.h l.160) manpage: setsid
- setuid
-
setuid( uid_t uid) + (../include/syscall_stubs.h l.162) manpage: setuid
- sleep
-
unsigned int volatile sleep(unsigned int seconds);
Defines: nanosleep
(../src/process/sleep.c l.10) manpage: sleep
nonconformant sleep
TODO: ignore blocked signals, sigchld - tcgetattr
-
int tcgetattr(int fd, struct termios *io); + Defines: ioctl termio
(../src/termios/tcgetattr.c l.12) manpage: tcgetattr - tcgetpgrp
-
int tcgetpgrp(int fd); + (../src/termios/tcgetpgrp.c l.2) manpage: tcgetpgrp
- tcsetattr
-
int tcsetattr(int fd, int opt, const struct termios *io); + Defines: termio ioctl
(../src/termios/tcsetattr.c l.12) manpage: tcsetattr - tcsetpgrp
-
int tcsetpgrp(int fd, int pgrp); + (../src/termios/tcsetpgrp.c l.2) manpage: tcsetpgrp
- unlink
-
unlink( const char* path) + (../include/syscall_stubs.h l.109) manpage: unlink
- usleep
-
unsigned int volatile usleep(unsigned int useconds);
Defines: nanosleep
(../src/process/sleep.c l.31) manpage: usleep
nonconformant usleep.
Sleep useconds.
I just hope, noone relies on an exact sleep time.
which isn’t possible without a real time os, anyways.
When for whatever reason you’d need nanoseconds exact times,
best shot might be a spinloop, and looking for cpu ticks.
TODO: ignore blocked signals, sigchld - write
-
write(int fd,const void *buf, int len ) + (../include/syscall_stubs.h l.104) manpage: write