* cp/semantics.c (prune_unused_decls): New function.
[official-gcc.git] / libiberty / getpagesize.c
blob564d6c02312f4935262ef95ae580eb3d301ab271
1 /* Emulation of getpagesize() for systems that need it. */
3 /*
5 NAME
7 getpagesize -- return the number of bytes in page of memory
9 SYNOPSIS
11 int getpagesize (void)
13 DESCRIPTION
15 Returns the number of bytes in a page of memory. This is the
16 granularity of many of the system memory management routines.
17 No guarantee is made as to whether or not it is the same as the
18 basic memory management hardware page size.
20 BUGS
22 Is intended as a reasonable replacement for systems where this
23 is not provided as a system call. The value of 4096 may or may
24 not be correct for the systems where it is returned as the default
25 value.
29 #ifndef VMS
31 #include "config.h"
33 #include <sys/types.h>
34 #ifdef HAVE_SYS_PARAM_H
35 #include <sys/param.h>
36 #endif
38 #undef GNU_OUR_PAGESIZE
39 #if defined (HAVE_SYSCONF) && defined (HAVE_UNISTD_H)
40 #include <unistd.h>
41 #ifdef _SC_PAGESIZE
42 #define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE)
43 #endif
44 #endif
46 #ifndef GNU_OUR_PAGESIZE
47 # ifdef PAGESIZE
48 # define GNU_OUR_PAGESIZE PAGESIZE
49 # else /* no PAGESIZE */
50 # ifdef EXEC_PAGESIZE
51 # define GNU_OUR_PAGESIZE EXEC_PAGESIZE
52 # else /* no EXEC_PAGESIZE */
53 # ifdef NBPG
54 # define GNU_OUR_PAGESIZE (NBPG * CLSIZE)
55 # ifndef CLSIZE
56 # define CLSIZE 1
57 # endif /* CLSIZE */
58 # else /* no NBPG */
59 # ifdef NBPC
60 # define GNU_OUR_PAGESIZE NBPC
61 # else /* no NBPC */
62 # define GNU_OUR_PAGESIZE 4096 /* Just punt and use reasonable value */
63 # endif /* NBPC */
64 # endif /* NBPG */
65 # endif /* EXEC_PAGESIZE */
66 # endif /* PAGESIZE */
67 #endif /* GNU_OUR_PAGESIZE */
69 int
70 getpagesize ()
72 return (GNU_OUR_PAGESIZE);
75 #else /* VMS */
77 #if 0 /* older distributions of gcc-vms are missing <syidef.h> */
78 #include <syidef.h>
79 #endif
80 #ifndef SYI$_PAGE_SIZE /* VMS V5.4 and earlier didn't have this yet */
81 #define SYI$_PAGE_SIZE 4452
82 #endif
83 extern unsigned long lib$getsyi(const unsigned short *,...);
85 int getpagesize ()
87 long pagsiz = 0L;
88 unsigned short itmcod = SYI$_PAGE_SIZE;
90 (void) lib$getsyi (&itmcod, (void *) &pagsiz);
91 if (pagsiz == 0L)
92 pagsiz = 512L; /* VAX default */
93 return (int) pagsiz;
96 #endif /* VMS */