5 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
8 Desc: AROS version of BPTRs
13 # include <exec/types.h>
17 #ifndef AROS_BPTR_TYPE
18 # ifdef AROS_FAST_BPTR
19 # define AROS_BPTR_TYPE APTR
21 # define AROS_BPTR_TYPE IPTR
24 #ifndef AROS_BSTR_TYPE
25 # ifdef AROS_FAST_BSTR
26 # define AROS_BSTR_TYPE STRPTR
28 # define AROS_BSTR_TYPE IPTR
32 typedef AROS_BPTR_TYPE BPTR
;
33 typedef AROS_BSTR_TYPE BSTR
;
35 /* In the BCPL language memory is addressed in chunks of long (e.g. 32 bit) and also
36 * the BPTRs on used by DOS on amigaos used this addressing. This is contrary to byte
37 * (e.g. 8 bit) addressing as is common now for most architectures.
39 * AROS can be configured to have BPTRs also use byte addressing by setting the
40 * AROS_FAST_BPTR preprocessor symbol in the cpu.h file.
41 * For source code compatibility AROS__FAST_BPTR should only be used for non-standard
42 * AROS implementations.
44 * MKBADDR and BADDR macros are defined to access BPTRs in an implementation
48 # define MKBADDR(a) ((BPTR)(a))
49 # define BADDR(a) ((APTR)a)
51 # define MKBADDR(a) ((BPTR)(((IPTR)a)>>2))
52 # define BADDR(a) ((APTR)(((IPTR)a)<<2))
55 /* BCPL strings used the first byte as the length of the string followed by the string.
56 * Strings then also had a maximum length of 255. The normal C convention is to have
57 * strings of any length but ended with a byte value of 0
59 * AROS can be configured to have BSTRs implemented as C strings by setting the
60 * AROS_FAST_BSTR preprocessor symbol in the cpu.h file.
61 * For source code compatibility AROS_FAST_BSTR should only be used for non-standard
62 * AROS implementations.
64 * The AROS_BSTR_ADDR, AROS_BSTR_strlen, AROS_BSTR_setstrlen and AROS_BSTR_MEMSIZE4LEN
65 * preprocessor macros are provided to work with BSTRs in an implementation independent
69 # define AROS_BSTR_ADDR(s) ((STRPTR)BADDR(s))
70 # define AROS_BSTR_strlen(s) (strlen(AROS_BSTR_ADDR(s)))
71 # define AROS_BSTR_setstrlen(s,l) (AROS_BSTR_ADDR(s)[l] = 0)
72 # define AROS_BSTR_MEMSIZE4LEN(l) ((l)+1)
74 # define AROS_BSTR_ADDR(s) (((STRPTR)BADDR(s))+1)
75 # define AROS_BSTR_strlen(s) (AROS_BSTR_ADDR(s)[-1])
76 # define AROS_BSTR_setstrlen(s,l) do { \
77 STRPTR _s = AROS_BSTR_ADDR(s); \
81 # define AROS_BSTR_MEMSIZE4LEN(l) ((l)+2)
83 #define AROS_BSTR_getchar(s,l) (AROS_BSTR_ADDR(s)[l])
84 #define AROS_BSTR_putchar(s,l,c) (AROS_BSTR_ADDR(s)[l] = c)
86 #endif /* DOS_BPTR_H */