source: trunk/libs/newlib/src/newlib/libc/machine/spu/include/ea.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 4.8 KB
Line 
1/*
2(C) Copyright IBM Corp. 2007, 2008
3
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9* Redistributions of source code must retain the above copyright notice,
10this list of conditions and the following disclaimer.
11* Redistributions in binary form must reproduce the above copyright
12notice, this list of conditions and the following disclaimer in the
13documentation and/or other materials provided with the distribution.
14* Neither the name of IBM nor the names of its contributors may be
15used to endorse or promote products derived from this software without
16specific prior written permission.
17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY 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
52typedef uint64_t size_ea_t;
53typedef int64_t ssize_ea_t;
54typedef uint64_t key_ea_t;
55#define MAP_FAILED_EA ((__ea void *) -1LL)
56
57#else
58
59typedef uint32_t size_ea_t;
60typedef int32_t ssize_ea_t;
61typedef uint32_t key_ea_t;
62#define MAP_FAILED_EA ((__ea void *) -1)
63
64#endif
65
66typedef __ea void * eaptr;
67struct 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);
84int 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);
87int 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);
91void 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);
94int 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 */
107int memcmp_ea (__ea void *s1, __ea const void *s2, size_ea_t n);
108int strcmp_ea (__ea char *s1, __ea const char *s2);
109int 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);
114size_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);
117size_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);
122size_ea_t strlen_ea (__ea const char *s);
123
124/* Linux system call functions */
125ssize_ea_t read_ea(int fd, __ea void *buf, size_ea_t count);
126ssize_ea_t pread_ea(int fd, __ea void *buf, size_ea_t count, off_t offset);
127ssize_ea_t readv_ea(int fd, struct iovec_ea *vector, int count);
128ssize_ea_t write_ea(int fd, __ea const void *buf, size_ea_t count);
129ssize_ea_t pwrite_ea(int fd, __ea const void *buf, size_ea_t count, off_t offset);
130ssize_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
Note: See TracBrowser for help on using the repository browser.