]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/getpagesize.c
Daily bump.
[thirdparty/gcc.git] / libiberty / getpagesize.c
CommitLineData
6599da04
JM
1/* Emulation of getpagesize() for systems that need it. */
2
3/*
4
7f8fa05d 5@deftypefn Supplemental int getpagesize (void)
6599da04 6
aaa5f039
DD
7Returns the number of bytes in a page of memory. This is the
8granularity of many of the system memory management routines. No
9guarantee is made as to whether or not it is the same as the basic
10memory management hardware page size.
6599da04 11
aaa5f039 12@end deftypefn
6599da04
JM
13
14BUGS
15
16 Is intended as a reasonable replacement for systems where this
17 is not provided as a system call. The value of 4096 may or may
18 not be correct for the systems where it is returned as the default
19 value.
20
21*/
22
23#ifndef VMS
24
3affd5f0
JL
25#include "config.h"
26
6599da04 27#include <sys/types.h>
3affd5f0 28#ifdef HAVE_SYS_PARAM_H
6599da04
JM
29#include <sys/param.h>
30#endif
31
b9256371
MH
32#undef GNU_OUR_PAGESIZE
33#if defined (HAVE_SYSCONF) && defined (HAVE_UNISTD_H)
6599da04 34#include <unistd.h>
b9256371 35#ifdef _SC_PAGESIZE
6599da04 36#define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE)
b9256371
MH
37#endif
38#endif
39
40#ifndef GNU_OUR_PAGESIZE
41# ifdef PAGESIZE
42# define GNU_OUR_PAGESIZE PAGESIZE
43# else /* no PAGESIZE */
44# ifdef EXEC_PAGESIZE
45# define GNU_OUR_PAGESIZE EXEC_PAGESIZE
46# else /* no EXEC_PAGESIZE */
47# ifdef NBPG
48# define GNU_OUR_PAGESIZE (NBPG * CLSIZE)
49# ifndef CLSIZE
50# define CLSIZE 1
51# endif /* CLSIZE */
52# else /* no NBPG */
53# ifdef NBPC
54# define GNU_OUR_PAGESIZE NBPC
55# else /* no NBPC */
56# define GNU_OUR_PAGESIZE 4096 /* Just punt and use reasonable value */
57# endif /* NBPC */
58# endif /* NBPG */
59# endif /* EXEC_PAGESIZE */
60# endif /* PAGESIZE */
61#endif /* GNU_OUR_PAGESIZE */
6599da04
JM
62
63int
6da879de 64getpagesize (void)
6599da04
JM
65{
66 return (GNU_OUR_PAGESIZE);
67}
68
69#else /* VMS */
70
71#if 0 /* older distributions of gcc-vms are missing <syidef.h> */
72#include <syidef.h>
73#endif
74#ifndef SYI$_PAGE_SIZE /* VMS V5.4 and earlier didn't have this yet */
75#define SYI$_PAGE_SIZE 4452
76#endif
77extern unsigned long lib$getsyi(const unsigned short *,...);
78
6da879de 79int getpagesize (void)
6599da04
JM
80{
81 long pagsiz = 0L;
82 unsigned short itmcod = SYI$_PAGE_SIZE;
83
84 (void) lib$getsyi (&itmcod, (void *) &pagsiz);
85 if (pagsiz == 0L)
86 pagsiz = 512L; /* VAX default */
87 return (int) pagsiz;
88}
89
90#endif /* VMS */