gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-support/gbcompress/zx0/libdivsufsort/divsufsort_private.h
1 /*
2 * divsufsort_private.h for libdivsufsort
3 * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following
12 * conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27 #ifndef _DIVSUFSORT_PRIVATE_H
28 #define _DIVSUFSORT_PRIVATE_H 1
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
34 #include "divsufsort_config.h"
35 #include <assert.h>
36 #include <stdio.h>
37 #if HAVE_STRING_H
38 # include <string.h>
39 #endif
40 #if HAVE_STDLIB_H
41 # include <stdlib.h>
42 #endif
43 #if HAVE_MEMORY_H
44 # include <memory.h>
45 #endif
46 #if HAVE_STDDEF_H
47 # include <stddef.h>
48 #endif
49 #if HAVE_STRINGS_H
50 # include <strings.h>
51 #endif
52 #if HAVE_INTTYPES_H
53 # include <inttypes.h>
54 #else
55 # if HAVE_STDINT_H
56 # include <stdint.h>
57 # endif
58 #endif
59 #if defined(BUILD_DIVSUFSORT64)
60 # include "divsufsort64.h"
61 # ifndef SAIDX_T
62 # define SAIDX_T
63 # define saidx_t saidx64_t
64 # endif /* SAIDX_T */
65 # ifndef PRIdSAIDX_T
66 # define PRIdSAIDX_T PRIdSAIDX64_T
67 # endif /* PRIdSAIDX_T */
68 # define divsufsort divsufsort64
69 # define divbwt divbwt64
70 # define divsufsort_version divsufsort64_version
71 # define bw_transform bw_transform64
72 # define inverse_bw_transform inverse_bw_transform64
73 # define sufcheck sufcheck64
74 # define sa_search sa_search64
75 # define sa_simplesearch sa_simplesearch64
76 # define sssort sssort64
77 # define trsort trsort64
78 #else
79 # include "divsufsort.h"
80 #endif
81
82
83 /*- Constants -*/
84 #if !defined(UINT8_MAX)
85 # define UINT8_MAX (255)
86 #endif /* UINT8_MAX */
87 #if defined(ALPHABET_SIZE) && (ALPHABET_SIZE < 1)
88 # undef ALPHABET_SIZE
89 #endif
90 #if !defined(ALPHABET_SIZE)
91 # define ALPHABET_SIZE (UINT8_MAX + 1)
92 #endif
93 /* for divsufsort.c */
94 #define BUCKET_A_SIZE (ALPHABET_SIZE)
95 #define BUCKET_B_SIZE (ALPHABET_SIZE * ALPHABET_SIZE)
96 /* for sssort.c */
97 #if defined(SS_INSERTIONSORT_THRESHOLD)
98 # if SS_INSERTIONSORT_THRESHOLD < 1
99 # undef SS_INSERTIONSORT_THRESHOLD
100 # define SS_INSERTIONSORT_THRESHOLD (1)
101 # endif
102 #else
103 # define SS_INSERTIONSORT_THRESHOLD (8)
104 #endif
105 #if defined(SS_BLOCKSIZE)
106 # if SS_BLOCKSIZE < 0
107 # undef SS_BLOCKSIZE
108 # define SS_BLOCKSIZE (0)
109 # elif 32768 <= SS_BLOCKSIZE
110 # undef SS_BLOCKSIZE
111 # define SS_BLOCKSIZE (32767)
112 # endif
113 #else
114 # define SS_BLOCKSIZE (1024)
115 #endif
116 /* minstacksize = log(SS_BLOCKSIZE) / log(3) * 2 */
117 #if SS_BLOCKSIZE == 0
118 # if defined(BUILD_DIVSUFSORT64)
119 # define SS_MISORT_STACKSIZE (96)
120 # else
121 # define SS_MISORT_STACKSIZE (64)
122 # endif
123 #elif SS_BLOCKSIZE <= 4096
124 # define SS_MISORT_STACKSIZE (16)
125 #else
126 # define SS_MISORT_STACKSIZE (24)
127 #endif
128 #if defined(BUILD_DIVSUFSORT64)
129 # define SS_SMERGE_STACKSIZE (64)
130 #else
131 # define SS_SMERGE_STACKSIZE (32)
132 #endif
133 /* for trsort.c */
134 #define TR_INSERTIONSORT_THRESHOLD (8)
135 #if defined(BUILD_DIVSUFSORT64)
136 # define TR_STACKSIZE (96)
137 #else
138 # define TR_STACKSIZE (64)
139 #endif
140
141
142 /*- Macros -*/
143 #ifndef SWAP
144 # define SWAP(_a, _b) do { t = (_a); (_a) = (_b); (_b) = t; } while(0)
145 #endif /* SWAP */
146 #ifndef MIN
147 # define MIN(_a, _b) (((_a) < (_b)) ? (_a) : (_b))
148 #endif /* MIN */
149 #ifndef MAX
150 # define MAX(_a, _b) (((_a) > (_b)) ? (_a) : (_b))
151 #endif /* MAX */
152 #define STACK_PUSH(_a, _b, _c, _d)\
153 do {\
154 assert(ssize < STACK_SIZE);\
155 stack[ssize].a = (_a), stack[ssize].b = (_b),\
156 stack[ssize].c = (_c), stack[ssize++].d = (_d);\
157 } while(0)
158 #define STACK_PUSH5(_a, _b, _c, _d, _e)\
159 do {\
160 assert(ssize < STACK_SIZE);\
161 stack[ssize].a = (_a), stack[ssize].b = (_b),\
162 stack[ssize].c = (_c), stack[ssize].d = (_d), stack[ssize++].e = (_e);\
163 } while(0)
164 #define STACK_POP(_a, _b, _c, _d)\
165 do {\
166 assert(0 <= ssize);\
167 if(ssize == 0) { return; }\
168 (_a) = stack[--ssize].a, (_b) = stack[ssize].b,\
169 (_c) = stack[ssize].c, (_d) = stack[ssize].d;\
170 } while(0)
171 #define STACK_POP5(_a, _b, _c, _d, _e)\
172 do {\
173 assert(0 <= ssize);\
174 if(ssize == 0) { return; }\
175 (_a) = stack[--ssize].a, (_b) = stack[ssize].b,\
176 (_c) = stack[ssize].c, (_d) = stack[ssize].d, (_e) = stack[ssize].e;\
177 } while(0)
178 /* for divsufsort.c */
179 #define BUCKET_A(_c0) bucket_A[(_c0)]
180 #if ALPHABET_SIZE == 256
181 #define BUCKET_B(_c0, _c1) (bucket_B[((_c1) << 8) | (_c0)])
182 #define BUCKET_BSTAR(_c0, _c1) (bucket_B[((_c0) << 8) | (_c1)])
183 #else
184 #define BUCKET_B(_c0, _c1) (bucket_B[(_c1) * ALPHABET_SIZE + (_c0)])
185 #define BUCKET_BSTAR(_c0, _c1) (bucket_B[(_c0) * ALPHABET_SIZE + (_c1)])
186 #endif
187
188
189 /*- Private Prototypes -*/
190 /* sssort.c */
191 void
192 sssort(const sauchar_t *Td, const saidx_t *PA,
193 saidx_t *first, saidx_t *last,
194 saidx_t *buf, saidx_t bufsize,
195 saidx_t depth, saidx_t n, saint_t lastsuffix);
196 /* trsort.c */
197 void
198 trsort(saidx_t *ISA, saidx_t *SA, saidx_t n, saidx_t depth);
199
200
201 #ifdef __cplusplus
202 } /* extern "C" */
203 #endif /* __cplusplus */
204
205 #endif /* _DIVSUFSORT_PRIVATE_H */
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.