1 | /* |
---|
2 | (C) Copyright IBM Corp. 2007, 2008 |
---|
3 | |
---|
4 | All rights reserved. |
---|
5 | |
---|
6 | Redistribution and use in source and binary forms, with or without |
---|
7 | modification, are permitted provided that the following conditions are met: |
---|
8 | |
---|
9 | * Redistributions of source code must retain the above copyright notice, |
---|
10 | this list of conditions and the following disclaimer. |
---|
11 | * Redistributions in binary form must reproduce the above copyright |
---|
12 | notice, this list of conditions and the following disclaimer in the |
---|
13 | documentation and/or other materials provided with the distribution. |
---|
14 | * Neither the name of IBM nor the names of its contributors may be |
---|
15 | used to endorse or promote products derived from this software without |
---|
16 | specific prior written permission. |
---|
17 | |
---|
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
28 | POSSIBILITY OF SUCH DAMAGE. |
---|
29 | |
---|
30 | */ |
---|
31 | |
---|
32 | #ifndef __EA_H |
---|
33 | #define __EA_H |
---|
34 | |
---|
35 | #include <stdint.h> |
---|
36 | #include <stddef.h> |
---|
37 | #include <sys/syscall.h> |
---|
38 | #include <sys/types.h> |
---|
39 | #include <sys/unistd.h> |
---|
40 | |
---|
41 | /* |
---|
42 | * take this out when compiler support is common |
---|
43 | */ |
---|
44 | #if (!defined( __EA32__ ) && !defined( __EA64__ )) |
---|
45 | #warning "need __ea support in compiler to compile to take advantage of libea features" |
---|
46 | #define __ea |
---|
47 | #define __EA32__ |
---|
48 | #endif |
---|
49 | |
---|
50 | #ifdef __EA64__ |
---|
51 | |
---|
52 | typedef uint64_t size_ea_t; |
---|
53 | typedef int64_t ssize_ea_t; |
---|
54 | typedef uint64_t key_ea_t; |
---|
55 | #define MAP_FAILED_EA ((__ea void *) -1LL) |
---|
56 | |
---|
57 | #else |
---|
58 | |
---|
59 | typedef uint32_t size_ea_t; |
---|
60 | typedef int32_t ssize_ea_t; |
---|
61 | typedef uint32_t key_ea_t; |
---|
62 | #define MAP_FAILED_EA ((__ea void *) -1) |
---|
63 | |
---|
64 | #endif |
---|
65 | |
---|
66 | typedef __ea void * eaptr; |
---|
67 | struct iovec_ea |
---|
68 | { |
---|
69 | #ifdef __EA32__ |
---|
70 | unsigned int __pad1; /* 32 bit padding */ |
---|
71 | #endif |
---|
72 | /*__ea void *iov_base;*/ |
---|
73 | eaptr iov_base; /* Starting address */ |
---|
74 | #ifdef __EA32__ |
---|
75 | unsigned int __pad2; /* 32 bit padding */ |
---|
76 | #endif |
---|
77 | size_ea_t iov_len; /* Number of bytes */ |
---|
78 | }; |
---|
79 | |
---|
80 | |
---|
81 | /* Memory Mapping functions */ |
---|
82 | __ea void *mmap_ea (__ea void *start, size_ea_t length, int prot, int |
---|
83 | flags, int fd, off_t offset); |
---|
84 | int munmap_ea (__ea void *start, size_ea_t length); |
---|
85 | __ea void *mremap_ea (__ea void *old_address, size_ea_t old_size, |
---|
86 | size_ea_t new_size, unsigned long flags); |
---|
87 | int msync_ea (__ea void *start, size_ea_t length, int flags); |
---|
88 | |
---|
89 | /* EA memory mangement functions */ |
---|
90 | __ea void *calloc_ea (size_ea_t nmemb, size_ea_t length); |
---|
91 | void free_ea (__ea void *ptr); |
---|
92 | __ea void *malloc_ea (size_ea_t size); |
---|
93 | __ea void *realloc_ea (__ea void *ptr, size_ea_t size); |
---|
94 | int posix_memalign_ea (__ea void **memptr, size_ea_t alignment, size_ea_t size); |
---|
95 | |
---|
96 | /* String copying functions */ |
---|
97 | __ea void *memcpy_ea (__ea void *dest, __ea const void *src, size_ea_t n); |
---|
98 | __ea void *memmove_ea (__ea void *dest, __ea const void *src, size_ea_t n); |
---|
99 | __ea char *strcpy_ea (__ea char *dest, __ea const char *src); |
---|
100 | __ea char *strncpy_ea (__ea char *dest, __ea const char *src, size_ea_t n); |
---|
101 | |
---|
102 | /* Concatenation functions */ |
---|
103 | __ea char *strcat_ea (__ea char *dest, __ea const char *src); |
---|
104 | __ea char *strncat_ea (__ea char *dest, __ea const char *src, size_ea_t n); |
---|
105 | |
---|
106 | /* Comparison functions */ |
---|
107 | int memcmp_ea (__ea void *s1, __ea const void *s2, size_ea_t n); |
---|
108 | int strcmp_ea (__ea char *s1, __ea const char *s2); |
---|
109 | int strncmp_ea (__ea void *s1, __ea const void *s2, size_ea_t n3); |
---|
110 | |
---|
111 | /* Search functions*/ |
---|
112 | __ea void *memchr_ea (__ea const void *s, int c, size_ea_t n); |
---|
113 | __ea char *strchr_ea (__ea const char *s, int c); |
---|
114 | size_ea_t strcspn_ea (__ea const char *s, const char *reject); |
---|
115 | __ea char *strpbrk_ea (__ea const char *s, const char *accept); |
---|
116 | __ea char *strrchr_ea (__ea const char *s, int c); |
---|
117 | size_ea_t strspn_ea (__ea const char *s, const char *accept); |
---|
118 | __ea char * strstr_ea (__ea const char *s1, __ea const char *s2); |
---|
119 | |
---|
120 | /* Misc functions */ |
---|
121 | __ea void *memset_ea (__ea void *dest, int c, size_ea_t n); |
---|
122 | size_ea_t strlen_ea (__ea const char *s); |
---|
123 | |
---|
124 | /* Linux system call functions */ |
---|
125 | ssize_ea_t read_ea(int fd, __ea void *buf, size_ea_t count); |
---|
126 | ssize_ea_t pread_ea(int fd, __ea void *buf, size_ea_t count, off_t offset); |
---|
127 | ssize_ea_t readv_ea(int fd, struct iovec_ea *vector, int count); |
---|
128 | ssize_ea_t write_ea(int fd, __ea const void *buf, size_ea_t count); |
---|
129 | ssize_ea_t pwrite_ea(int fd, __ea const void *buf, size_ea_t count, off_t offset); |
---|
130 | ssize_ea_t writev_ea(int fd, struct iovec_ea *vector, int count); |
---|
131 | |
---|
132 | |
---|
133 | #if defined( __EA64__ ) && defined( __EA32__ ) |
---|
134 | #error __EA64__ and __EA32__ are both defined |
---|
135 | #endif |
---|
136 | |
---|
137 | #endif |
---|