![]() |
libbsd headers and library |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This is wholly untested software! Use it at your own risk!
|
These options will cause the compiler to look in those locations prior to looking elsewhere. Whenever a /usr/include/bsd exists, it will be used in place of any corresponding /usr/include file. Nothing is lost, however, since each /usr/include/bsd file also includes its /usr/include counterpart.
Most of these files are rather trivial, but some are rather hefty. Go exploring and let me know what looks good/bad at arpa-www@cup.hp.com. All mail will be examined, no guarantees of any action beyond that.
05/13/2016 May 13 2016 - Keven Miller
Added missing file: bsd/machine/param.h
Added missing file: bsd/machine/spl.h
Corrected #include in bsd/strings.hRemoved define of getpgrp from bsd/signal.h which should be associated with unistd.hBefore: #include "/bsd/include/string.h"
After: #include "/usr/include/bsd/string.h"
This was generating compile warning 2006.Removed second, already defined macro of w_termsig in bsd/sys/wait.hBefore: #define getpgrp(pid) getpgrp(pid)
After: #ifdef NOT_HERE /* getpgrp 20160514 Keven Miller */ /* getpgrp defined in /usr/include/unistd.h with no parm (POSIX) getpgrp defined as a macro with a parm in /usr/include/bsd/signal.h (BSD) BSD version of getpgrp has a parm. Since getpgrp not in libbsd.a, use posix version. and remove macro for getpgrp */ #define getpgrp(pid) getpgrp(pid) #endif /* NOT_HERE getpgrp */Added file bsd/varargs.h to redefine the MASK constants as unsigned types.Before: # define w_termsig w_T.w_Termsig # define w_coredump w_T.w_Coredump # define w_retcode w_T.w_Retcode extern pid_t wait3(int *stat_loc, int options, struct rusage *reserved); #define w_termsig w_status & W_KILL_MASK
After: # define w_termsig w_T.w_Termsig # define w_coredump w_T.w_Coredump # define w_retcode w_T.w_Retcode extern pid_t wait3(int *stat_loc, int options, struct rusage *reserved); /* #define w_termsig w_status & W_KILL_MASK */ /* 20160513 Keven Miller removed define because conflicts with above define */
This removes compile warning 700 ANSI migration.#ifndef _BSD_VARARGS_H #define _BSD_VARARGS_H #include "/usr/include/varargs.h" #undef __WORD_MASK #undef __DW_MASK #define __WORD_MASK 0xFFFFFFFCu #define __DW_MASK 0xFFFFFFF8u #endif /* _BSD_VARARGS_H */
ftp> bin 200 Type set to I. ftp> quote site posix on 200 POSIX command ok. ftp> put libbsd.tar.Z 200 PORT command ok. 150 File: libbsd.tar.Z opened; data connection will be opened 226 Transfer complete. ftp: 2693615 bytes sent in 2.48Seconds 1084.39Kbytes/sec. ftp>
/usr/lib/libbsd.a
/usr/include/bsd
/KEVENM/POSIX#ls -l libbsd* -rwxrwx--- 1 MGR.KEVENM KEVENM 2693632 May 17 07:22 libbsd.tar.Z /KEVENM/POSIX# /KEVENM/POSIX#uncompress libbsd.tar.Z /KEVENM/POSIX# /KEVENM/POSIX#ls -l libbsd* -rwxrwx--- 1 MGR.KEVENM KEVENM 5907464 May 17 11:56 libbsd.tar /KEVENM/POSIX# /KEVENM/POSIX#tar -xvopf libbsd.tar tar: blocksize = 20 x /usr/lib/libbsd.a, 5614080 bytes, 10965 tape blocks x /usr/include/bsd/a.out.h, 41 bytes, 1 tape block x /usr/include/bsd/ar.h, 668 bytes, 2 tape blocks x /usr/include/bsd/db.h, 6756 bytes, 14 tape blocks x /usr/include/bsd/dirent.h, 84 bytes, 1 tape block x /usr/include/bsd/errno.h, 55 bytes, 1 tape block x /usr/include/bsd/fcntl.h, 155 bytes, 1 tape block x /usr/include/bsd/ftw.h, 1856 bytes, 4 tape blocks x /usr/include/bsd/glob.h, 3074 bytes, 7 tape blocks x /usr/include/bsd/mnttab.h, 5069 bytes, 10 tape blocks x /usr/include/bsd/mpe.h, 919 bytes, 2 tape blocks x /usr/include/bsd/mpool.h, 5225 bytes, 11 tape blocks x /usr/include/bsd/ndbm.h, 2819 bytes, 6 tape blocks x /usr/include/bsd/nl_types.h, 52 bytes, 1 tape block x /usr/include/bsd/nlist.h, 390 bytes, 1 tape block x /usr/include/bsd/paths.h, 2936 bytes, 6 tape blocks x /usr/include/bsd/pwd.h, 2142 bytes, 5 tape blocks x /usr/include/bsd/resolv.h, 3043 bytes, 6 tape blocks x /usr/include/bsd/sgtty.h, 26 bytes, 1 tape block x /usr/include/bsd/signal.h, 1003 bytes, 2 tape blocks x /usr/include/bsd/stdio.h, 105 bytes, 1 tape block x /usr/include/bsd/stdlib.h, 3131 bytes, 7 tape blocks x /usr/include/bsd/string.h, 391 bytes, 1 tape block x /usr/include/bsd/strings.h, 37 bytes, 1 tape block x /usr/include/bsd/sysexits.h, 408 bytes, 1 tape block x /usr/include/bsd/syslog.h, 24 bytes, 1 tape block x /usr/include/bsd/termios.h, 622 bytes, 2 tape blocks x /usr/include/bsd/time.h, 107 bytes, 1 tape block x /usr/include/bsd/tzfile.h, 5120 bytes, 10 tape blocks x /usr/include/bsd/unistd.h, 190 bytes, 1 tape block x /usr/include/bsd/utmp.h, 2314 bytes, 5 tape blocks x /usr/include/bsd/varargs.h, 211 bytes, 1 tape block x /usr/include/bsd/arpa/ftp.h, 3646 bytes, 8 tape blocks x /usr/include/bsd/arpa/nameser.h, 7837 bytes, 16 tape blocks x /usr/include/bsd/arpa/telnet.h, 10035 bytes, 20 tape blocks x /usr/include/bsd/arpa/tftp.h, 2960 bytes, 6 tape blocks x /usr/include/bsd/machine/endian.h, 545 bytes, 2 tape blocks x /usr/include/bsd/machine/param.h, 58 bytes, 1 tape block x /usr/include/bsd/machine/spl.h, 56 bytes, 1 tape block x /usr/include/bsd/net/if.h, 11173 bytes, 22 tape blocks x /usr/include/bsd/net/if_arp.h, 3029 bytes, 6 tape blocks x /usr/include/bsd/netinet/in.h, 68 bytes, 1 tape block x /usr/include/bsd/netinet/in_systm.h, 1629 bytes, 4 tape blocks x /usr/include/bsd/netinet/ip.h, 4142 bytes, 9 tape blocks x /usr/include/bsd/netinet/ip_icmp.h, 4470 bytes, 9 tape blocks x /usr/include/bsd/netinet/ip_var.h, 4544 bytes, 9 tape blocks x /usr/include/bsd/protocols/rwhod.h, 1736 bytes, 4 tape blocks x /usr/include/bsd/protocols/talkd.h, 5090 bytes, 10 tape blocks x /usr/include/bsd/rpc/rpc.h, 22 bytes, 1 tape block x /usr/include/bsd/sys/cdefs.h, 3694 bytes, 8 tape blocks x /usr/include/bsd/sys/dir.h, 20 bytes, 1 tape block x /usr/include/bsd/sys/errno.h, 32 bytes, 1 tape block x /usr/include/bsd/sys/file.h, 19 bytes, 1 tape block x /usr/include/bsd/sys/ioctl.h, 10600 bytes, 21 tape blocks x /usr/include/bsd/sys/mman.h, 3577 bytes, 7 tape blocks x /usr/include/bsd/sys/param.h, 12747 bytes, 25 tape blocks x /usr/include/bsd/sys/resource.h, 2310 bytes, 5 tape blocks x /usr/include/bsd/sys/signal.h, 20 bytes, 1 tape block x /usr/include/bsd/sys/socket.h, 67 bytes, 1 tape block x /usr/include/bsd/sys/stat.h, 111 bytes, 1 tape block x /usr/include/bsd/sys/statfs.h, 8213 bytes, 17 tape blocks x /usr/include/bsd/sys/stdsyms.h, 3806 bytes, 8 tape blocks x /usr/include/bsd/sys/syslog.h, 6665 bytes, 14 tape blocks x /usr/include/bsd/sys/time.h, 190 bytes, 1 tape block x /usr/include/bsd/sys/ttychars.h, 2784 bytes, 6 tape blocks x /usr/include/bsd/sys/wait.h, 1045 bytes, 3 tape blocks /KEVENM/POSIX# /KEVENM/POSIX#ls -l /usr/lib/libb* -rw-r--r-- 1 MGR.KEVENM 0 5614080 Feb 28 2001 /usr/lib/libbsd.a /KEVENM/POSIX#
ftp> bin 200 Type set to I. ftp> quote site posix on 200 POSIX command ok. ftp> put bsd.tar.Z 200 PORT command ok. 150 File: bsd.tar.Z opened; data connection will be opened 226 Transfer complete. ftp: 2696595 bytes sent in 2.45Seconds 1099.30Kbytes/sec. ftp>
/KEVENM/POSIX#ls -l bsd* -rwxrwx--- 1 MGR.KEVENM KEVENM 2696704 May 17 11:56 bsd.tar.Z /KEVENM/POSIX# /KEVENM/POSIX#uncompress bsd* /KEVENM/POSIX# /KEVENM/POSIX#ls -l bsd* -rwxrwx--- 1 MGR.KEVENM KEVENM 5907510 May 17 11:56 bsd.tar /KEVENM/POSIX# /KEVENM/POSIX#tar -xvopf bsd.tar tar: blocksize = 20 x bsd/a.out.h, 41 bytes, 1 tape block x bsd/ar.h, 668 bytes, 2 tape blocks x bsd/db.h, 6756 bytes, 14 tape blocks x bsd/dirent.h, 84 bytes, 1 tape block x bsd/errno.h, 55 bytes, 1 tape block x bsd/fcntl.h, 155 bytes, 1 tape block x bsd/ftw.h, 1856 bytes, 4 tape blocks x bsd/glob.h, 3074 bytes, 7 tape blocks x bsd/libbsd.a, 5614080 bytes, 10965 tape blocks ... x bsd/sys/wait.h, 972 bytes, 2 tape blocks /KEVENM/POSIX# /KEVENM/POSIX#ls -l bsd* drw-r--r-- 9 MGR.KEVENM KEVENM 3872 May 11 11:56 bsd -rwxrwx--- 1 MGR.KEVENM KEVENM 5907510 May 17 11:56 bsd.tar /KEVENM/POSIX# /KEVENM/POSIX#ls -l bsd/lib* -rw-r--r-- 1 MGR.KEVENM KEVENM 5614080 Feb 28 2001 bsd/libbsd.a /KEVENM/POSIX#
The definition of getpgrp in /usr/include/unistd.h/KEVENM/POSIX#cat w2006.c #include <stdio.h> /* printf */ #include <unistd.h> /* getpgrp */ #include <signal.h> /* getpgrp */ int main () { int gid; gid = getpgrp (); printf ("GID %d\n", gid); }
The definition of getpgrp in /usr/include/bsd/signal.h/KEVENM/POSIX#grep " getpgrp" /usr/include/unistd.h extern pid_t getpgrp(void); extern pid_t getpgrp();
Compiling with "NOT_HERE" defined we see the warning./KEVENM/POSIX#grep getpgrp /usr/include/bsd/signal.h #ifdef NOT_HERE /* getpgrp 20160514 Keven Miller */ /* getpgrp defined in /usr/include/unistd.h with no parm (POSIX) getpgrp defined as a macro with a parm in /usr/include/bsd/signal.h (BSD) BSD version of getpgrp has a parm. Since getpgrp not in libbsd.a, use posix version. and remove macro for getpgrp */ #define getpgrp(pid) getpgrp(pid) #endif /* NOT_HERE getpgrp */
#c89 -D_POSIX_SOURCE -DNOT_HERE -I/usr/include/bsd -o w2006 w2006.c
cpp: "/KEVENM/POSIX/w2006.c", line 9: warning 2006: Parameter holes filled with a null string.
#
Compile with normal includes from /usr/include/KEVENM/POSIX#cat wvararg.c #include <stdio.h> /* vprintf */ #include <varargs.h> /* va_start va_arg va_end va_list */ void doout (va_alist) va_dcl { va_list args; char *fmt; va_start (args); fmt = va_arg (args, char*); vprintf (fmt, args); va_end (args); } int main () { doout ("Int %d\n", 7); doout ("Chr %s\n", "String"); }
/KEVENM/POSIX#grep MASK /usr/include/varargs.hCompile using the new bsd/varargs.h
# define __WORD_MASK 0xFFFFFFFC
# define __DW_MASK 0xFFFFFFF8
/KEVENM/POSIX#c89 -o wvararg wvararg.c
cc: "/KEVENM/POSIX/wvararg.c", line 11: warning 530: Casting from loose to strict alignment.
cc: "/KEVENM/POSIX/wvararg.c", line 11: warning 700: ANSI migration: large unsuffixed integer constants will not be of type long in ANSI mode.
cc: "/KEVENM/POSIX/wvararg.c", line 11: warning 700: ANSI migration: large unsuffixed integer constants will not be of type long in ANSI mode.
cc: "/KEVENM/POSIX/wvararg.c", line 11: warning 530: Casting from loose to strict alignment.
/KEVENM/POSIX#grep MASK /usr/include/bsd/varargs.hThe warning "530: casting from loose to strict alignment" is difficult to find. The macro va_arg is long and complex. Although it works just fine, one day I hope to compile with no warnings! Here are the relative lines from /usr/include/varargs.h
#undef __WORD_MASK
#undef __DW_MASK
#define __WORD_MASK 0xFFFFFFFCu
#define __DW_MASK 0xFFFFFFF8u
/KEVENM/POSIX#c89 -I/usr/include/bsd -o wvararg wvararg.c
cc: "/KEVENM/POSIX/wvararg.c", line 11: warning 530: Casting from loose to strict alignment.
cc: "/KEVENM/POSIX/wvararg.c", line 11: warning 530: Casting from loose to strict alignment.
typedef double *va_list; # define __WORD_MASK 0xFFFFFFFC # define __DW_MASK 0xFFFFFFF8 # define va_arg(__list,__mode) \ (sizeof(__mode) > 8 ? \ ((__list = (va_list) ((char *)__list - sizeof (int))), \ (*((__mode *) (*((int *) (__list)))))) : \ ((__list = \ (va_list) ((long)((char *)__list - sizeof (__mode)) \ & (sizeof(__mode) > 4 ? __DW_MASK : __WORD_MASK))), \ (*((__mode *) ((char *)__list + \ ((8 - sizeof(__mode)) % 4))))))