libbsd headers and library

jazz.external.hp.com
» jazz home
software downloads
» papers & training
» java
This is wholly untested software! Use it at your own risk!
  1. Usage
  2. Maintenance
  3. Installation
  4. Download
  5. (End of Page)

Usage

This package contains /usr/lib/libbsd.a which is an RL of many BSD functions from the NetBSD distribution ported to the HP3000. This package also contains a forward compatible set of include files required to access the functions in the library. Each of these include files has a reference to its corresponding /usr/include file (if such exists). To use the library, add -lbsd when linking. To use the includes, add -I/usr/include/bsd when compiling. When using the header files, keep in mind that they have not been rigorously examined for MPE compatibility. They work so far as to port things found on this server, no guarantees. The headers in bsd/sys/* may not be used with KERNEL, _KERNEL_BUILD, USE_OLD_TTY, or COMPAT_43 defined. These defines will cause the headers to fail to compile or compile incorrectly. These defines are not supported. The associated code has been left intact as a reference.

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.


Maintenance

1/10/95 - Fixed syslog to use vfprintf. Added cuserid, fchdir, ffs, ftime, readv, sighold, siginterrupt, sigrelse, sigignore, truncate functions.
6/16/95 - Moved all includes from /bsd/include to /usr/include/bsd. Added notes about restricting #defines in bsd/sys directory.

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.h
Before: #include "/bsd/include/string.h"
After:  #include "/usr/include/bsd/string.h"
Removed define of getpgrp from bsd/signal.h which should be associated with unistd.h
This was generating compile warning 2006.
Before: #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 */
Removed second, already defined macro of w_termsig in bsd/sys/wait.h
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 */
Added file bsd/varargs.h to redefine the MASK constants as unsigned types.
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 */
    

Installation instructions


Download

Compile warning 2006

HPC/iX (c89) can issue an undocumented warning 2006.
It appears to come when a macro parameter is not provided.
In the following example, the function getpgrp() declared in unistd.h and defined in POSIX, has no parameters.
In BSD and the bsd/signal.h file, it is defined with one parameter.
/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/unistd.h
/KEVENM/POSIX#grep " getpgrp" /usr/include/unistd.h
       extern pid_t getpgrp(void);
       extern pid_t getpgrp();
The definition of getpgrp in /usr/include/bsd/signal.h
/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 */
Compiling with "NOT_HERE" defined we see the warning.
#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.
#

Warnings from using varargs.h

The following program gives warnings on the line using the macro va_arg defined in varargs.h.
The ANSI migration warnings can be removed by redefining the MASK constants to be unsigned types.
/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");
} 
Compile with normal includes from /usr/include
/KEVENM/POSIX#grep MASK /usr/include/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.
Compile using the new bsd/varargs.h
/KEVENM/POSIX#grep MASK /usr/include/bsd/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.
The 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
   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))))))   

Top    Bixby    Hosted by 3kRanger.com    email 3kRanger    Updated