cheader-filesminix

Same type defined in two header files


In the source code of MINIX 3 described in Tanenbaum's MINIX book, the line typedef void _PROTOTYPE( (*sighandler_t),(int) ); appears in both include/signal.h and sys/types.h. Why is it defined twice?

EDIT: In sys/types.h some of the surrounding code is:

#ifndef _TYPES_H
#define _TYPES_H

#ifndef _ANSI_H
#include <ansi.h>
#endif

/* ........(too long to write)....... */

#if _EM_WSIZE == 2
/*typedef unsigned int Ino_t; Ino_t is now 32 bits */
typedef unsigned int Zone1_t;
typedef unsigned int Bitchunk_t;
typedef unsigned int Bitchunk_t;
typedef unsigned int U16_t;
typedef unsigned int _mnx_Mode_t;

#else /* _EM_WSIZE == 4, or _EM_WSIZE undefined */
/* typedef int Ino_t; Ino_t is now 32 bits */
typedef int Zone1_t;
typedef int Bitchunk_t;
typedef int U16_t;
typedef int _mnx_Mode_t;

#endif /* _EM_WSIZE == 2, etc */

/* Signal handler type, e.g. SIG_IGN */
typedef void _PROTOTYPE( (*sighandler_t), (int) );

And in include/signal.h:

#ifndef _ANSI_H
#include <ansi.h>
#endif
#ifdef _POSIX_SOURCE
#ifndef _TYPES_H
#include <sys/types.h>
#endif
#endif

/* .......(too long to write)....... */

/* POSIX requires the following signals to be defined, even if they are
 * not supported. Here are the definitions, but they are not supported.
*/
 #define SIGCONT 18 /* continue if stopped */
 #define SIGSTOP 19 /* stop signal */
 #define SIGTSTP 20 /* interactive stop signal */
 #define SIGTTIN 21 /* background process wants to read */
 #define SIGTTOU 22 /* background process wants to write */

/* The sighandler_t type is not allowed unless _POSIX_SOURCE is defined. */
 typedef void _PROTOTYPE( (*__sighandler_t), (int) );

The full files can be found here


Solution

  • Why is it defined twice?

    ...because humans are fallible. It seems to be nothing but a bug/omission. Minix 3 is an evolving project and that bug eventually got fixed.