GnuCOBOL  2.0
A free COBOL compiler
codeoptim.c File Reference
#include "config.h"
#include "defaults.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include "cobc.h"
#include "tree.h"
Include dependency graph for codeoptim.c:

Go to the source code of this file.

Functions

static void output_storage (const char *fmt,...)
 
void cob_gen_optim (const enum cb_optim val)
 

Function Documentation

void cob_gen_optim ( const enum cb_optim  val)

Definition at line 48 of file codeoptim.c.

References _, COB_ADD_ALIGN_S16, COB_ADD_ALIGN_S32, COB_ADD_ALIGN_S64, COB_ADD_ALIGN_U16, COB_ADD_ALIGN_U32, COB_ADD_ALIGN_U64, COB_ADD_PACKED_INT, COB_ADD_S16, COB_ADD_S24, COB_ADD_S32, COB_ADD_S40, COB_ADD_S48, COB_ADD_S56, COB_ADD_S64, COB_ADD_S8, COB_ADD_U16, COB_ADD_U24, COB_ADD_U32, COB_ADD_U40, COB_ADD_U48, COB_ADD_U56, COB_ADD_U64, COB_ADD_U8, COB_ADDSWP_S16, COB_ADDSWP_S24, COB_ADDSWP_S32, COB_ADDSWP_S40, COB_ADDSWP_S48, COB_ADDSWP_S56, COB_ADDSWP_S64, COB_ADDSWP_U16, COB_ADDSWP_U24, COB_ADDSWP_U32, COB_ADDSWP_U40, COB_ADDSWP_U48, COB_ADDSWP_U56, COB_ADDSWP_U64, COB_CMP_ALIGN_S16, COB_CMP_ALIGN_S32, COB_CMP_ALIGN_S64, COB_CMP_ALIGN_U16, COB_CMP_ALIGN_U32, COB_CMP_ALIGN_U64, COB_CMP_PACKED_INT, COB_CMP_S16, COB_CMP_S24, COB_CMP_S32, COB_CMP_S40, COB_CMP_S48, COB_CMP_S56, COB_CMP_S64, COB_CMP_S8, COB_CMP_U16, COB_CMP_U24, COB_CMP_U32, COB_CMP_U40, COB_CMP_U48, COB_CMP_U56, COB_CMP_U64, COB_CMP_U8, COB_CMPSWP_ALIGN_S16, COB_CMPSWP_ALIGN_S32, COB_CMPSWP_ALIGN_S64, COB_CMPSWP_ALIGN_U16, COB_CMPSWP_ALIGN_U32, COB_CMPSWP_ALIGN_U64, COB_CMPSWP_S16, COB_CMPSWP_S24, COB_CMPSWP_S32, COB_CMPSWP_S40, COB_CMPSWP_S48, COB_CMPSWP_S56, COB_CMPSWP_S64, COB_CMPSWP_U16, COB_CMPSWP_U24, COB_CMPSWP_U32, COB_CMPSWP_U40, COB_CMPSWP_U48, COB_CMPSWP_U56, COB_CMPSWP_U64, COB_GET_NUMDISP, COB_GET_PACKED_INT, COB_POINTER_MANIP, COB_SET_SCREEN, COB_SETSWP_S16, COB_SETSWP_S24, COB_SETSWP_S32, COB_SETSWP_S40, COB_SETSWP_S48, COB_SETSWP_S56, COB_SETSWP_S64, COB_SETSWP_U16, COB_SETSWP_U24, COB_SETSWP_U32, COB_SETSWP_U40, COB_SETSWP_U48, COB_SETSWP_U56, COB_SETSWP_U64, COB_SUB_ALIGN_S16, COB_SUB_ALIGN_S32, COB_SUB_ALIGN_S64, COB_SUB_ALIGN_U16, COB_SUB_ALIGN_U32, COB_SUB_ALIGN_U64, COB_SUB_S16, COB_SUB_S24, COB_SUB_S32, COB_SUB_S40, COB_SUB_S48, COB_SUB_S56, COB_SUB_S64, COB_SUB_S8, COB_SUB_U16, COB_SUB_U24, COB_SUB_U32, COB_SUB_U40, COB_SUB_U48, COB_SUB_U56, COB_SUB_U64, COB_SUB_U8, COB_SUBSWP_S16, COB_SUBSWP_S24, COB_SUBSWP_S32, COB_SUBSWP_S40, COB_SUBSWP_S48, COB_SUBSWP_S56, COB_SUBSWP_S64, COB_SUBSWP_U16, COB_SUBSWP_U24, COB_SUBSWP_U32, COB_SUBSWP_U40, COB_SUBSWP_U48, COB_SUBSWP_U56, COB_SUBSWP_U64, COBC_ABORT, cobc_abort_pr(), and output_storage().

Referenced by codegen().

49 {
50  switch (val) {
51 
52  case COB_SET_SCREEN:
53  output_storage ("static void COB_NOINLINE");
54  output_storage ("cob_set_screen (cob_screen *s, cob_screen *next,");
55  output_storage (" cob_screen *prev, cob_screen *child, cob_screen *parent,");
56  output_storage (" cob_field *field, cob_field *value,");
57  output_storage (" cob_field *line, cob_field *column,");
58  output_storage (" cob_field *foreg, cob_field *backg, cob_field *prompt,");
59  output_storage (" const int type, const int occurs, const int attr)");
60  output_storage ("{");
61  output_storage (" s->next = next;");
62  output_storage (" s->prev = prev;");
63  output_storage (" s->child = child;");
64  output_storage (" s->parent = parent;");
65  output_storage (" s->field = field;");
66  output_storage (" s->value = value;");
67  output_storage (" s->line = line;");
68  output_storage (" s->column = column;");
69  output_storage (" s->foreg = foreg;");
70  output_storage (" s->backg = backg;");
71  output_storage (" s->prompt = prompt;");
72  output_storage (" s->type = type;");
73  output_storage (" s->occurs = occurs;");
74  output_storage (" s->attr = attr;");
75  output_storage ("}");
76  return;
77 
78  case COB_POINTER_MANIP:
79  output_storage ("static void COB_NOINLINE");
80  output_storage ("cob_pointer_manip (cob_field *f1, cob_field *f2, const unsigned int addsub)");
81  output_storage ("{");
82  output_storage (" unsigned char *tmptr;");
83  output_storage (" memcpy (&tmptr, f1->data, sizeof(void *));");
84  output_storage (" if (addsub) {");
85  output_storage (" tmptr -= cob_get_int (f2);");
86  output_storage (" } else {");
87  output_storage (" tmptr += cob_get_int (f2);");
88  output_storage (" }");
89  output_storage (" memcpy (f1->data, &tmptr, sizeof(void *));");
90  output_storage ("}");
91  return;
92 
93  case COB_GET_NUMDISP:
94  output_storage ("static int COB_NOINLINE");
95  output_storage ("cob_get_numdisp (const void *data, const size_t size)");
96  output_storage ("{");
97  output_storage (" const unsigned char *p;");
98  output_storage (" size_t n;");
99  output_storage (" int retval;");
100 
101  output_storage (" p = (const unsigned char *)data;");
102  output_storage (" retval = 0;");
103  output_storage (" for (n = 0; n < size; ++n, ++p) {");
104  output_storage (" retval *= 10;");
105  output_storage (" retval += (*p & 0x0F);");
106  output_storage (" }");
107  output_storage (" return retval;");
108  output_storage ("}");
109  return;
110 
111  case COB_CMP_PACKED_INT:
112  output_storage ("static int COB_NOINLINE");
113  output_storage ("cob_cmp_packed_int (const cob_field *f, const cob_s64_t n)");
114  output_storage ("{");
115  output_storage (" unsigned char *p;");
116  output_storage (" size_t size;");
117  output_storage (" cob_s64_t val;");
118 
119  output_storage (" val = 0;");
120  output_storage (" p = f->data;");
121  output_storage (" for (size = 0; size < f->size - 1; ++size, ++p) {");
122  output_storage (" val *= 10;");
123  output_storage (" val += *p >> 4;");
124  output_storage (" val *= 10;");
125  output_storage (" val += *p & 0x0f;");
126  output_storage (" }");
127  output_storage (" val *= 10;");
128  output_storage (" val += *p >> 4;");
129  output_storage (" if ((*p & 0x0f) == 0x0d) {");
130  output_storage (" val = -val;");
131  output_storage (" }");
132  output_storage (" return (val < n) ? -1 : (val > n);");
133  output_storage ("}");
134  return;
135 
136  case COB_GET_PACKED_INT:
137  output_storage ("static int COB_NOINLINE");
138  output_storage ("cob_get_packed_int (const cob_field *f)");
139  output_storage ("{");
140  output_storage (" unsigned char *p;");
141  output_storage (" size_t size;");
142  output_storage (" int val = 0;");
143 
144  output_storage (" p = f->data;");
145  output_storage (" for (size = 0; size < f->size - 1; ++size, ++p) {");
146  output_storage (" val *= 10;");
147  output_storage (" val += *p >> 4;");
148  output_storage (" val *= 10;");
149  output_storage (" val += *p & 0x0f;");
150  output_storage (" }");
151  output_storage (" val *= 10;");
152  output_storage (" val += *p >> 4;");
153  output_storage (" if ((*p & 0x0f) == 0x0d) {");
154  output_storage (" val = -val;");
155  output_storage (" }");
156  output_storage (" return val;");
157  output_storage ("}");
158  return;
159 
160  case COB_ADD_PACKED_INT:
161  output_storage ("static int COB_NOINLINE");
162  output_storage ("cob_add_packed_int (cob_field *f, const int val)");
163  output_storage ("{");
164  output_storage (" unsigned char *p;");
165  output_storage (" size_t size;");
166  output_storage (" int carry = 0;");
167  output_storage (" int n;");
168  output_storage (" int inc;");
169 
170  output_storage (" if (val == 0) {");
171  output_storage (" return 0;");
172  output_storage (" }");
173  output_storage (" p = f->data + f->size - 1;");
174  output_storage (" if ((*p & 0x0f) == 0x0d) {");
175  output_storage (" if (val > 0) {");
176  output_storage (" return cob_add_int (f, val, 0);");
177  output_storage (" }");
178  output_storage (" n = -val;");
179  output_storage (" } else {");
180  output_storage (" if (val < 0) {");
181  output_storage (" return cob_add_int (f, val, 0);");
182  output_storage (" }");
183  output_storage (" n = val;");
184  output_storage (" }");
185  output_storage (" inc = (*p >> 4) + (n %% 10);");
186  output_storage (" n /= 10;");
187  output_storage (" carry = inc / 10;");
188  output_storage (" *p = ((inc %% 10) << 4) | (*p & 0x0f);");
189  output_storage (" p--;");
190 
191  output_storage (" for (size = 0; size < f->size - 1; ++size, --p) {");
192  output_storage (" if (!carry && !n) {");
193  output_storage (" break;");
194  output_storage (" }");
195  output_storage (" inc = ((*p >> 4) * 10) + (*p & 0x0f) + carry + (n %% 100);");
196  output_storage (" carry = inc / 100;");
197  output_storage (" n /= 100;");
198  output_storage (" inc %%= 100;");
199  output_storage (" *p = ((inc / 10) << 4) | (inc %% 10);");
200  output_storage (" }");
201  output_storage (" return 0;");
202  output_storage ("}");
203  return;
204 
205  /* Aligned variants */
206 
207  /* Aligned compares */
208 
209  case COB_CMP_ALIGN_U16:
210  output_storage ("static COB_INLINE COB_A_INLINE int");
211  output_storage ("cob_cmp_align_u16 (const void *p, const cob_s64_t n)");
212  output_storage ("{");
213  output_storage (" unsigned short val;");
214 
215  output_storage (" if (unlikely(n < 0)) {");
216  output_storage (" return 1;");
217  output_storage (" }");
218  output_storage (" val = *(unsigned short __unaligned *)p;");
219  output_storage (" return (val < n) ? -1 : (val > n);");
220  output_storage ("}");
221  return;
222 
223  case COB_CMP_ALIGN_S16:
224  output_storage ("static COB_INLINE COB_A_INLINE int");
225  output_storage ("cob_cmp_align_s16 (const void *p, const cob_s64_t n)");
226  output_storage ("{");
227  output_storage (" short val;");
228 
229  output_storage (" val = *(short __unaligned *)p;");
230  output_storage (" return (val < n) ? -1 : (val > n);");
231  output_storage ("}");
232  return;
233 
234  case COB_CMP_ALIGN_U32:
235  output_storage ("static COB_INLINE COB_A_INLINE int");
236  output_storage ("cob_cmp_align_u32 (const void *p, const cob_s64_t n)");
237  output_storage ("{");
238  output_storage (" unsigned int val;");
239 
240  output_storage (" if (unlikely(n < 0)) {");
241  output_storage (" return 1;");
242  output_storage (" }");
243  output_storage (" val = *(unsigned int __unaligned *)p;");
244  output_storage (" return (val < n) ? -1 : (val > n);");
245  output_storage ("}");
246  return;
247 
248  case COB_CMP_ALIGN_S32:
249  output_storage ("static COB_INLINE COB_A_INLINE int");
250  output_storage ("cob_cmp_align_s32 (const void *p, const cob_s64_t n)");
251  output_storage ("{");
252  output_storage (" int val;");
253 
254  output_storage (" val = *(int __unaligned *)p;");
255  output_storage (" return (val < n) ? -1 : (val > n);");
256  output_storage ("}");
257  return;
258 
259  case COB_CMP_ALIGN_U64:
260  output_storage ("static COB_INLINE COB_A_INLINE int");
261  output_storage ("cob_cmp_align_u64 (const void *p, const cob_s64_t n)");
262  output_storage ("{");
263  output_storage (" cob_u64_t val;");
264 
265  output_storage (" if (unlikely(n < 0)) {");
266  output_storage (" return 1;");
267  output_storage (" }");
268  output_storage (" val = *(cob_u64_t __unaligned *)p;");
269  output_storage (" return (val < n) ? -1 : (val > n);");
270  output_storage ("}");
271  return;
272 
273  case COB_CMP_ALIGN_S64:
274  output_storage ("static COB_INLINE COB_A_INLINE int");
275  output_storage ("cob_cmp_align_s64 (const void *p, const cob_s64_t n)");
276  output_storage ("{");
277  output_storage (" cob_s64_t val;");
278 
279  output_storage (" val = *(cob_s64_t __unaligned *)p;");
280  output_storage (" return (val < n) ? -1 : (val > n);");
281  output_storage ("}");
282  return;
283 
284  /* Aligned adds */
285 
286  case COB_ADD_ALIGN_U16:
287  output_storage ("static COB_INLINE COB_A_INLINE void");
288  output_storage ("cob_add_align_u16 (void *p, const int val)");
289  output_storage ("{");
290  output_storage (" *(unsigned short __unaligned *)p += val;");
291  output_storage ("}");
292  return;
293 
294  case COB_ADD_ALIGN_S16:
295  output_storage ("static COB_INLINE COB_A_INLINE void");
296  output_storage ("cob_add_align_s16 (void *p, const int val)");
297  output_storage ("{");
298  output_storage (" *(short __unaligned *)p += val;");
299  output_storage ("}");
300  return;
301 
302  case COB_ADD_ALIGN_U32:
303  output_storage ("static COB_INLINE COB_A_INLINE void");
304  output_storage ("cob_add_align_u32 (void *p, const int val)");
305  output_storage ("{");
306  output_storage (" *(unsigned int __unaligned *)p += val;");
307  output_storage ("}");
308  return;
309 
310  case COB_ADD_ALIGN_S32:
311  output_storage ("static COB_INLINE COB_A_INLINE void");
312  output_storage ("cob_add_align_s32 (void *p, const int val)");
313  output_storage ("{");
314  output_storage (" *(int __unaligned *)p += val;");
315  output_storage ("}");
316  return;
317 
318  case COB_ADD_ALIGN_U64:
319  output_storage ("static COB_INLINE COB_A_INLINE void");
320  output_storage ("cob_add_align_u64 (void *p, const int val)");
321  output_storage ("{");
322  output_storage (" *(cob_u64_t __unaligned *)p += val;");
323  output_storage ("}");
324  return;
325 
326  case COB_ADD_ALIGN_S64:
327  output_storage ("static COB_INLINE COB_A_INLINE void");
328  output_storage ("cob_add_align_s64 (void *p, const int val)");
329  output_storage ("{");
330  output_storage (" *(cob_s64_t __unaligned *)p += val;");
331  output_storage ("}");
332  return;
333 
334  /* Aligned subtracts */
335 
336  case COB_SUB_ALIGN_U16:
337  output_storage ("static COB_INLINE COB_A_INLINE void");
338  output_storage ("cob_sub_align_u16 (void *p, const int val)");
339  output_storage ("{");
340  output_storage (" *(unsigned short __unaligned *)p -= val;");
341  output_storage ("}");
342  return;
343 
344  case COB_SUB_ALIGN_S16:
345  output_storage ("static COB_INLINE COB_A_INLINE void");
346  output_storage ("cob_sub_align_s16 (void *p, const int val)");
347  output_storage ("{");
348  output_storage (" *(short __unaligned *)p -= val;");
349  output_storage ("}");
350  return;
351 
352  case COB_SUB_ALIGN_U32:
353  output_storage ("static COB_INLINE COB_A_INLINE void");
354  output_storage ("cob_sub_align_u32 (void *p, const int val)");
355  output_storage ("{");
356  output_storage (" *(unsigned int __unaligned *)p -= val;");
357  output_storage ("}");
358  return;
359 
360  case COB_SUB_ALIGN_S32:
361  output_storage ("static COB_INLINE COB_A_INLINE void");
362  output_storage ("cob_sub_align_s32 (void *p, const int val)");
363  output_storage ("{");
364  output_storage (" *(int __unaligned *)p -= val;");
365  output_storage ("}");
366  return;
367 
368  case COB_SUB_ALIGN_U64:
369  output_storage ("static COB_INLINE COB_A_INLINE void");
370  output_storage ("cob_sub_align_u64 (void *p, const int val)");
371  output_storage ("{");
372  output_storage (" *(cob_u64_t __unaligned *)p -= val;");
373  output_storage ("}");
374  return;
375 
376  case COB_SUB_ALIGN_S64:
377  output_storage ("static COB_INLINE COB_A_INLINE void");
378  output_storage ("cob_sub_align_s64 (void *p, const int val)");
379  output_storage ("{");
380  output_storage (" *(cob_s64_t __unaligned *)p -= val;");
381  output_storage ("}");
382  return;
383 
385  output_storage ("static COB_INLINE COB_A_INLINE int");
386  output_storage ("cob_cmpswp_align_u16 (const void *p, const cob_s64_t n)");
387  output_storage ("{");
388  output_storage (" unsigned short val;");
389 
390  output_storage (" if (unlikely(n < 0)) {");
391  output_storage (" return 1;");
392  output_storage (" }");
393  output_storage (" val = COB_BSWAP_16 (*(unsigned short __unaligned *)p);");
394  output_storage (" return (val < n) ? -1 : (val > n);");
395  output_storage ("}");
396  return;
397 
399  output_storage ("static COB_INLINE COB_A_INLINE int");
400  output_storage ("cob_cmpswp_align_s16 (const void *p, const cob_s64_t n)");
401  output_storage ("{");
402  output_storage (" short val;");
403 
404  output_storage (" val = COB_BSWAP_16 (*(short __unaligned *)p);");
405  output_storage (" return (val < n) ? -1 : (val > n);");
406  output_storage ("}");
407  return;
408 
410  output_storage ("static COB_INLINE COB_A_INLINE int");
411  output_storage ("cob_cmpswp_align_u32 (const void *p, const cob_s64_t n)");
412  output_storage ("{");
413  output_storage (" unsigned int val;");
414 
415  output_storage (" if (unlikely(n < 0)) {");
416  output_storage (" return 1;");
417  output_storage (" }");
418  output_storage (" val = COB_BSWAP_32 (*(unsigned int __unaligned *)p);");
419  output_storage (" return (val < n) ? -1 : (val > n);");
420  output_storage ("}");
421  return;
422 
424  output_storage ("static COB_INLINE COB_A_INLINE int");
425  output_storage ("cob_cmpswp_align_s32 (const void *p, const cob_s64_t n)");
426  output_storage ("{");
427  output_storage (" int val;");
428 
429  output_storage (" val = COB_BSWAP_32 (*(int __unaligned *)p);");
430  output_storage (" return (val < n) ? -1 : (val > n);");
431  output_storage ("}");
432  return;
433 
435  output_storage ("static COB_INLINE COB_A_INLINE int");
436  output_storage ("cob_cmpswp_align_u64 (const void *p, const cob_s64_t n)");
437  output_storage ("{");
438  output_storage (" cob_u64_t val;");
439 
440  output_storage (" if (unlikely(n < 0)) {");
441  output_storage (" return 1;");
442  output_storage (" }");
443  output_storage (" val = COB_BSWAP_64 (*(cob_u64_t __unaligned *)p);");
444  output_storage (" return (val < n) ? -1 : (val > n);");
445  output_storage ("}");
446  return;
447 
449  output_storage ("static COB_INLINE COB_A_INLINE int");
450  output_storage ("cob_cmpswp_align_s64 (const void *p, const cob_s64_t n)");
451  output_storage ("{");
452  output_storage (" cob_s64_t val;");
453 
454  output_storage (" val = COB_BSWAP_64 (*(cob_s64_t __unaligned *)p);");
455  output_storage (" return (val < n) ? -1 : (val > n);");
456  output_storage ("}");
457  return;
458 
459  /* Binary compare */
460 
461  case COB_CMP_U8:
462  output_storage ("static COB_INLINE COB_A_INLINE int");
463  output_storage ("cob_cmp_u8 (const void *p, const cob_s64_t n)");
464  output_storage ("{");
465  output_storage (" if (unlikely(n < 0)) {");
466  output_storage (" return 1;");
467  output_storage (" }");
468  output_storage (" return (*(const unsigned char *)p < n) ? -1 : (*(const unsigned char *)p > n);");
469  output_storage ("}");
470  return;
471 
472  case COB_CMP_S8:
473  output_storage ("static COB_INLINE COB_A_INLINE int");
474  output_storage ("cob_cmp_s8 (const void *p, const cob_s64_t n)");
475  output_storage ("{");
476  output_storage (" return (*(const signed char *)p < n) ? -1 : (*(const signed char *)p > n);");
477  output_storage ("}");
478  return;
479 
480  case COB_CMP_U16:
481  output_storage ("static COB_INLINE COB_A_INLINE int");
482  output_storage ("cob_cmp_u16 (const void *p, const cob_s64_t n)");
483  output_storage ("{");
484 #ifndef COB_ALLOW_UNALIGNED
485  output_storage (" void *x;");
486 #endif
487  output_storage (" unsigned short val;");
488 
489  output_storage (" if (unlikely(n < 0)) {");
490  output_storage (" return 1;");
491  output_storage (" }");
492 #ifdef COB_ALLOW_UNALIGNED
493  output_storage (" val = *(const unsigned short __unaligned *)p;");
494 #else
495  output_storage (" x = &val;");
496  output_storage (" optim_memcpy (x, p, 2);");
497 #endif
498  output_storage (" return (val < n) ? -1 : (val > n);");
499  output_storage ("}");
500  return;
501 
502  case COB_CMP_S16:
503  output_storage ("static COB_INLINE COB_A_INLINE int");
504  output_storage ("cob_cmp_s16 (const void *p, const cob_s64_t n)");
505  output_storage ("{");
506  output_storage (" short val;");
507 
508 #ifdef COB_ALLOW_UNALIGNED
509  output_storage (" val = *(const short __unaligned *)p;");
510 #else
511  output_storage (" void *x;");
512 
513  output_storage (" x = &val;");
514  output_storage (" optim_memcpy (x, p, 2);");
515 #endif
516  output_storage (" return (val < n) ? -1 : (val > n);");
517  output_storage ("}");
518  return;
519 
520  case COB_CMP_U24:
521  output_storage ("static COB_INLINE COB_A_INLINE int");
522  output_storage ("cob_cmp_u24 (const void *p, const cob_s64_t n)");
523  output_storage ("{");
524  output_storage (" unsigned char *x;");
525  output_storage (" unsigned int val = 0;");
526 
527  output_storage (" if (unlikely(n < 0)) {");
528  output_storage (" return 1;");
529  output_storage (" }");
530 #ifdef WORDS_BIGENDIAN
531  output_storage (" x = ((unsigned char *)&val) + 1;");
532 #else
533  output_storage (" x = (unsigned char *)&val;");
534 #endif
535  output_storage (" optim_memcpy (x, p, 3);");
536  output_storage (" return (val < n) ? -1 : (val > n);");
537  output_storage ("}");
538  return;
539 
540  case COB_CMP_S24:
541  output_storage ("static COB_INLINE COB_A_INLINE int");
542  output_storage ("cob_cmp_s24 (const void *p, const cob_s64_t n)");
543  output_storage ("{");
544  output_storage (" unsigned char *x;");
545  output_storage (" int val = 0;");
546 
547 #ifdef WORDS_BIGENDIAN
548  output_storage (" x = (unsigned char *)&val;");
549 #else
550  output_storage (" x = ((unsigned char *)&val) + 1;");
551 #endif
552  output_storage (" optim_memcpy (x, p, 3);");
553  output_storage (" val >>= 8; /* Shift with sign */");
554  output_storage (" return (val < n) ? -1 : (val > n);");
555  output_storage ("}");
556  return;
557 
558  case COB_CMP_U32:
559  output_storage ("static COB_INLINE COB_A_INLINE int");
560  output_storage ("cob_cmp_u32 (const void *p, const cob_s64_t n)");
561  output_storage ("{");
562 #ifndef COB_ALLOW_UNALIGNED
563  output_storage (" void *x;");
564 #endif
565  output_storage (" unsigned int val;");
566 
567  output_storage (" if (unlikely(n < 0)) {");
568  output_storage (" return 1;");
569  output_storage (" }");
570 #ifdef COB_ALLOW_UNALIGNED
571  output_storage (" val = *(const unsigned int __unaligned *)p;");
572 #else
573  output_storage (" x = &val;");
574  output_storage (" optim_memcpy (x, p, 4);");
575 #endif
576  output_storage (" return (val < n) ? -1 : (val > n);");
577  output_storage ("}");
578  return;
579 
580  case COB_CMP_S32:
581  output_storage ("static COB_INLINE COB_A_INLINE int");
582  output_storage ("cob_cmp_s32 (const void *p, const cob_s64_t n)");
583  output_storage ("{");
584  output_storage (" int val;");
585 
586 #ifdef COB_ALLOW_UNALIGNED
587  output_storage (" val = *(const int __unaligned *)p;");
588 #else
589  output_storage (" void *x;");
590 
591  output_storage (" x = &val;");
592  output_storage (" optim_memcpy (x, p, 4);");
593 #endif
594  output_storage (" return (val < n) ? -1 : (val > n);");
595  output_storage ("}");
596  return;
597 
598  case COB_CMP_U40:
599  output_storage ("static COB_INLINE COB_A_INLINE int");
600  output_storage ("cob_cmp_u40 (const void *p, const cob_s64_t n)");
601  output_storage ("{");
602  output_storage (" cob_u64_t val = 0;");
603  output_storage (" unsigned char *x;");
604 
605  output_storage (" if (unlikely(n < 0)) {");
606  output_storage (" return 1;");
607  output_storage (" }");
608 #ifdef WORDS_BIGENDIAN
609  output_storage (" x = ((unsigned char *)&val) + 3;");
610 #else
611  output_storage (" x = (unsigned char *)&val;");
612 #endif
613  output_storage (" optim_memcpy (x, p, 5);");
614  output_storage (" return (val < n) ? -1 : (val > n);");
615  output_storage ("}");
616  return;
617 
618  case COB_CMP_S40:
619  output_storage ("static COB_INLINE COB_A_INLINE int");
620  output_storage ("cob_cmp_s40 (const void *p, const cob_s64_t n)");
621  output_storage ("{");
622  output_storage (" cob_s64_t val = 0;");
623  output_storage (" unsigned char *x;");
624 
625 #ifdef WORDS_BIGENDIAN
626  output_storage (" x = (unsigned char *)&val;");
627 #else
628  output_storage (" x = ((unsigned char *)&val) + 3;");
629 #endif
630  output_storage (" optim_memcpy (x, p, 5);");
631  output_storage (" val >>= 24; /* Shift with sign */");
632  output_storage (" return (val < n) ? -1 : (val > n);");
633  output_storage ("}");
634  return;
635 
636  case COB_CMP_U48:
637  output_storage ("static COB_INLINE COB_A_INLINE int");
638  output_storage ("cob_cmp_u48 (const void *p, const cob_s64_t n)");
639  output_storage ("{");
640  output_storage (" cob_u64_t val = 0;");
641  output_storage (" unsigned char *x;");
642 
643  output_storage (" if (unlikely(n < 0)) {");
644  output_storage (" return 1;");
645  output_storage (" }");
646 #ifdef WORDS_BIGENDIAN
647  output_storage (" x = ((unsigned char *)&val) + 2;");
648 #else
649  output_storage (" x = (unsigned char *)&val;");
650 #endif
651  output_storage (" optim_memcpy (x, p, 6);");
652  output_storage (" return (val < n) ? -1 : (val > n);");
653  output_storage ("}");
654  return;
655 
656  case COB_CMP_S48:
657  output_storage ("static COB_INLINE COB_A_INLINE int");
658  output_storage ("cob_cmp_s48 (const void *p, const cob_s64_t n)");
659  output_storage ("{");
660  output_storage (" cob_s64_t val = 0;");
661  output_storage (" unsigned char *x;");
662 
663 #ifdef WORDS_BIGENDIAN
664  output_storage (" x = (unsigned char *)&val;");
665 #else
666  output_storage (" x = ((unsigned char *)&val) + 2;");
667 #endif
668  output_storage (" optim_memcpy (x, p, 6);");
669  output_storage (" val >>= 16; /* Shift with sign */");
670  output_storage (" return (val < n) ? -1 : (val > n);");
671  output_storage ("}");
672  return;
673 
674  case COB_CMP_U56:
675  output_storage ("static COB_INLINE COB_A_INLINE int");
676  output_storage ("cob_cmp_u56 (const void *p, const cob_s64_t n)");
677  output_storage ("{");
678  output_storage (" cob_u64_t val = 0;");
679  output_storage (" unsigned char *x;");
680 
681  output_storage (" if (unlikely(n < 0)) {");
682  output_storage (" return 1;");
683  output_storage (" }");
684 #ifdef WORDS_BIGENDIAN
685  output_storage (" x = ((unsigned char *)&val) + 1;");
686 #else
687  output_storage (" x = (unsigned char *)&val;");
688 #endif
689  output_storage (" optim_memcpy (x, p, 7);");
690  output_storage (" return (val < n) ? -1 : (val > n);");
691  output_storage ("}");
692  return;
693 
694  case COB_CMP_S56:
695  output_storage ("static COB_INLINE COB_A_INLINE int");
696  output_storage ("cob_cmp_s56 (const void *p, const cob_s64_t n)");
697  output_storage ("{");
698  output_storage (" cob_s64_t val = 0;");
699  output_storage (" unsigned char *x;");
700 
701 #ifdef WORDS_BIGENDIAN
702  output_storage (" x = (unsigned char *)&val;");
703 #else
704  output_storage (" x = ((unsigned char *)&val) + 1;");
705 #endif
706  output_storage (" optim_memcpy (x, p, 7);");
707  output_storage (" val >>= 8; /* Shift with sign */");
708  output_storage (" return (val < n) ? -1 : (val > n);");
709  output_storage ("}");
710  return;
711 
712  case COB_CMP_U64:
713  output_storage ("static COB_INLINE COB_A_INLINE int");
714  output_storage ("cob_cmp_u64 (const void *p, const cob_s64_t n)");
715  output_storage ("{");
716 #ifndef COB_ALLOW_UNALIGNED
717  output_storage (" void *x;");
718 #endif
719  output_storage (" cob_u64_t val;");
720 
721  output_storage (" if (unlikely(n < 0)) {");
722  output_storage (" return 1;");
723  output_storage (" }");
724 #ifdef COB_ALLOW_UNALIGNED
725  output_storage (" val = *(const cob_u64_t __unaligned *)p;");
726 #else
727  output_storage (" x = &val;");
728  output_storage (" optim_memcpy (x, p, 8);");
729 #endif
730  output_storage (" return (val < n) ? -1 : (val > n);");
731  output_storage ("}");
732  return;
733 
734  case COB_CMP_S64:
735  output_storage ("static COB_INLINE COB_A_INLINE int");
736  output_storage ("cob_cmp_s64 (const void *p, const cob_s64_t n)");
737  output_storage ("{");
738  output_storage (" cob_s64_t val;");
739 
740 #ifdef COB_ALLOW_UNALIGNED
741  output_storage (" val = *(const cob_s64_t __unaligned *)p;");
742 #else
743  output_storage (" void *x;");
744 
745  output_storage (" x = &val;");
746  output_storage (" optim_memcpy (x, p, 8);");
747 #endif
748  output_storage (" return (val < n) ? -1 : (val > n);");
749  output_storage ("}");
750  return;
751 
752  /* Add/Subtract */
753 
754  case COB_ADD_U8:
755  output_storage ("static COB_INLINE COB_A_INLINE void");
756  output_storage ("cob_add_u8 (void *p, const int val)");
757  output_storage ("{");
758  output_storage (" *(unsigned char *)p += val;");
759  output_storage ("}");
760  return;
761 
762  case COB_ADD_S8:
763  output_storage ("static COB_INLINE COB_A_INLINE void");
764  output_storage ("cob_add_s8 (void *p, const int val)");
765  output_storage ("{");
766  output_storage (" *(signed char *)p += val;");
767  output_storage ("}");
768  return;
769 
770  case COB_ADD_U16:
771  output_storage ("static COB_INLINE COB_A_INLINE void");
772  output_storage ("cob_add_u16 (void *p, const int val)");
773  output_storage ("{");
774 #ifdef COB_ALLOW_UNALIGNED
775  output_storage (" *(unsigned short __unaligned *)p += val;");
776 #else
777  output_storage (" void *x;");
778  output_storage (" unsigned short n;");
779 
780  output_storage (" x = &n;");
781  output_storage (" optim_memcpy (x, p, 2);");
782  output_storage (" n += val;");
783  output_storage (" optim_memcpy (p, x, 2);");
784 #endif
785  output_storage ("}");
786  return;
787 
788  case COB_ADD_S16:
789  output_storage ("static COB_INLINE COB_A_INLINE void");
790  output_storage ("cob_add_s16 (void *p, const int val)");
791  output_storage ("{");
792 #ifdef COB_ALLOW_UNALIGNED
793  output_storage (" *(short __unaligned *)p += val;");
794 #else
795  output_storage (" void *x;");
796  output_storage (" short n;");
797 
798  output_storage (" x = &n;");
799  output_storage (" optim_memcpy (x, p, 2);");
800  output_storage (" n += val;");
801  output_storage (" optim_memcpy (p, x, 2);");
802 #endif
803  output_storage ("}");
804  return;
805 
806  case COB_ADD_U24:
807  output_storage ("static COB_INLINE COB_A_INLINE void");
808  output_storage ("cob_add_u24 (void *p, const int val)");
809  output_storage ("{");
810  output_storage (" unsigned char *x;");
811  output_storage (" unsigned int n = 0;");
812 
813 #ifdef WORDS_BIGENDIAN
814  output_storage (" x = ((unsigned char *)&n) + 1;");
815 #else
816  output_storage (" x = (unsigned char *)&n;");
817 #endif
818  output_storage (" optim_memcpy (x, p, 3);");
819  output_storage (" n += val;");
820  output_storage (" optim_memcpy (p, x, 3);");
821  output_storage ("}");
822  return;
823 
824  case COB_ADD_S24:
825  output_storage ("static COB_INLINE COB_A_INLINE void");
826  output_storage ("cob_add_s24 (void *p, const int val)");
827  output_storage ("{");
828  output_storage (" unsigned char *x;");
829  output_storage (" int n = 0;");
830 
831 #ifdef WORDS_BIGENDIAN
832  output_storage (" x = (unsigned char *)&n;");
833 #else
834  output_storage (" x = ((unsigned char *)&n) + 1;");
835 #endif
836  output_storage (" optim_memcpy (x, p, 3);");
837  output_storage (" n >>= 8; /* Shift with sign */");
838  output_storage (" n += val;");
839 #ifdef WORDS_BIGENDIAN
840  output_storage (" x = ((unsigned char *)&n) + 1;");
841 #else
842  output_storage (" x = (unsigned char *)&n;");
843 #endif
844  output_storage (" optim_memcpy (p, x, 3);");
845  output_storage ("}");
846  return;
847 
848  case COB_ADD_U32:
849  output_storage ("static COB_INLINE COB_A_INLINE void");
850  output_storage ("cob_add_u32 (void *p, const int val)");
851  output_storage ("{");
852 #ifdef COB_ALLOW_UNALIGNED
853  output_storage (" *(unsigned int __unaligned *)p += val;");
854 #else
855  output_storage (" void *x;");
856  output_storage (" unsigned int n;");
857 
858  output_storage (" x = &n;");
859  output_storage (" optim_memcpy (x, p, 4);");
860  output_storage (" n += val;");
861  output_storage (" optim_memcpy (p, x, 4);");
862 #endif
863  output_storage ("}");
864  return;
865 
866  case COB_ADD_S32:
867  output_storage ("static COB_INLINE COB_A_INLINE void");
868  output_storage ("cob_add_s32 (void *p, const int val)");
869  output_storage ("{");
870 #ifdef COB_ALLOW_UNALIGNED
871  output_storage (" *(int __unaligned *)p += val;");
872 #else
873  output_storage (" void *x;");
874  output_storage (" int n;");
875 
876  output_storage (" x = &n;");
877  output_storage (" optim_memcpy (x, p, 4);");
878  output_storage (" n += val;");
879  output_storage (" optim_memcpy (p, x, 4);");
880 #endif
881  output_storage ("}");
882  return;
883 
884  case COB_ADD_U40:
885  output_storage ("static COB_INLINE COB_A_INLINE void");
886  output_storage ("cob_add_u40 (void *p, const int val)");
887  output_storage ("{");
888  output_storage (" cob_u64_t n = 0;");
889  output_storage (" unsigned char *x;");
890 
891 #ifdef WORDS_BIGENDIAN
892  output_storage (" x = ((unsigned char *)&n) + 3;");
893 #else
894  output_storage (" x = (unsigned char *)&n;");
895 #endif
896  output_storage (" optim_memcpy (x, p, 5);");
897  output_storage (" n += val;");
898  output_storage (" optim_memcpy (p, x, 5);");
899  output_storage ("}");
900  return;
901 
902  case COB_ADD_S40:
903  output_storage ("static COB_INLINE COB_A_INLINE void");
904  output_storage ("cob_add_s40 (void *p, const int val)");
905  output_storage ("{");
906  output_storage (" cob_s64_t n = 0;");
907  output_storage (" unsigned char *x;");
908 
909 #ifdef WORDS_BIGENDIAN
910  output_storage (" x = (unsigned char *)&n;");
911 #else
912  output_storage (" x = ((unsigned char *)&n) + 3;");
913 #endif
914  output_storage (" optim_memcpy (x, p, 5);");
915  output_storage (" n >>= 24; /* Shift with sign */");
916  output_storage (" n += val;");
917 #ifdef WORDS_BIGENDIAN
918  output_storage (" x = ((unsigned char *)&n) + 3;");
919 #else
920  output_storage (" x = (unsigned char *)&n;");
921 #endif
922  output_storage (" optim_memcpy (p, x, 5);");
923  output_storage ("}");
924  return;
925 
926  case COB_ADD_U48:
927  output_storage ("static COB_INLINE COB_A_INLINE void");
928  output_storage ("cob_add_u48 (void *p, const int val)");
929  output_storage ("{");
930  output_storage (" cob_u64_t n = 0;");
931  output_storage (" unsigned char *x;");
932 
933 #ifdef WORDS_BIGENDIAN
934  output_storage (" x = ((unsigned char *)&n) + 2;");
935 #else
936  output_storage (" x = (unsigned char *)&n;");
937 #endif
938  output_storage (" optim_memcpy (x, p, 6);");
939  output_storage (" n += val;");
940  output_storage (" optim_memcpy (p, x, 6);");
941  output_storage ("}");
942  return;
943 
944  case COB_ADD_S48:
945  output_storage ("static COB_INLINE COB_A_INLINE void");
946  output_storage ("cob_add_s48 (void *p, const int val)");
947  output_storage ("{");
948  output_storage (" cob_s64_t n = 0;");
949  output_storage (" unsigned char *x;");
950 
951 #ifdef WORDS_BIGENDIAN
952  output_storage (" x = (unsigned char *)&n;");
953 #else
954  output_storage (" x = ((unsigned char *)&n) + 2;");
955 #endif
956  output_storage (" optim_memcpy (x, p, 6);");
957  output_storage (" n >>= 16; /* Shift with sign */");
958  output_storage (" n += val;");
959 #ifdef WORDS_BIGENDIAN
960  output_storage (" x = ((unsigned char *)&n) + 2;");
961 #else
962  output_storage (" x = (unsigned char *)&n;");
963 #endif
964  output_storage (" optim_memcpy (p, x, 6);");
965  output_storage ("}");
966  return;
967 
968  case COB_ADD_U56:
969  output_storage ("static COB_INLINE COB_A_INLINE void");
970  output_storage ("cob_add_u56 (void *p, const int val)");
971  output_storage ("{");
972  output_storage (" cob_u64_t n = 0;");
973  output_storage (" unsigned char *x;");
974 
975 #ifdef WORDS_BIGENDIAN
976  output_storage (" x = ((unsigned char *)&n) + 1;");
977 #else
978  output_storage (" x = (unsigned char *)&n;");
979 #endif
980  output_storage (" optim_memcpy (x, p, 7);");
981  output_storage (" n += val;");
982  output_storage (" optim_memcpy (p, x, 7);");
983  output_storage ("}");
984  return;
985 
986  case COB_ADD_S56:
987  output_storage ("static COB_INLINE COB_A_INLINE void");
988  output_storage ("cob_add_s56 (void *p, const int val)");
989  output_storage ("{");
990  output_storage (" cob_s64_t n = 0;");
991  output_storage (" unsigned char *x;");
992 
993 #ifdef WORDS_BIGENDIAN
994  output_storage (" x = (unsigned char *)&n;");
995 #else
996  output_storage (" x = ((unsigned char *)&n) + 1;");
997 #endif
998  output_storage (" optim_memcpy (x, p, 7);");
999  output_storage (" n >>= 8; /* Shift with sign */");
1000  output_storage (" n += val;");
1001 #ifdef WORDS_BIGENDIAN
1002  output_storage (" x = ((unsigned char *)&n) + 1;");
1003 #else
1004  output_storage (" x = (unsigned char *)&n;");
1005 #endif
1006  output_storage (" optim_memcpy (p, x, 7);");
1007  output_storage ("}");
1008  return;
1009 
1010  case COB_ADD_U64:
1011  output_storage ("static COB_INLINE COB_A_INLINE void");
1012  output_storage ("cob_add_u64 (void *p, const int val)");
1013  output_storage ("{");
1014 #ifdef COB_ALLOW_UNALIGNED
1015  output_storage (" *(cob_u64_t __unaligned *)p += val;");
1016 #else
1017  output_storage (" void *x;");
1018  output_storage (" cob_u64_t n;");
1019 
1020  output_storage (" x = &n;");
1021  output_storage (" optim_memcpy (x, p, 8);");
1022  output_storage (" n += val;");
1023  output_storage (" optim_memcpy (p, x, 8);");
1024 #endif
1025  output_storage ("}");
1026  return;
1027 
1028  case COB_ADD_S64:
1029  output_storage ("static COB_INLINE COB_A_INLINE void");
1030  output_storage ("cob_add_s64 (void *p, const int val)");
1031  output_storage ("{");
1032 #ifdef COB_ALLOW_UNALIGNED
1033  output_storage (" *(cob_s64_t __unaligned *)p += val;");
1034 #else
1035  output_storage (" void *x;");
1036  output_storage (" cob_s64_t n;");
1037 
1038  output_storage (" x = &n;");
1039  output_storage (" optim_memcpy (x, p, 8);");
1040  output_storage (" n += val;");
1041  output_storage (" optim_memcpy (p, x, 8);");
1042 #endif
1043  output_storage ("}");
1044  return;
1045 
1046  case COB_SUB_U8:
1047  output_storage ("static COB_INLINE COB_A_INLINE void");
1048  output_storage ("cob_sub_u8 (void *p, const int val)");
1049  output_storage ("{");
1050  output_storage (" *(unsigned char *)p -= val;");
1051  output_storage ("}");
1052  return;
1053 
1054  case COB_SUB_S8:
1055  output_storage ("static COB_INLINE COB_A_INLINE void");
1056  output_storage ("cob_sub_s8 (void *p, const int val)");
1057  output_storage ("{");
1058  output_storage (" *(signed char *)p -= val;");
1059  output_storage ("}");
1060  return;
1061 
1062  case COB_SUB_U16:
1063  output_storage ("static COB_INLINE COB_A_INLINE void");
1064  output_storage ("cob_sub_u16 (void *p, const int val)");
1065  output_storage ("{");
1066 #ifdef COB_ALLOW_UNALIGNED
1067  output_storage (" *(unsigned short __unaligned *)p -= val;");
1068 #else
1069  output_storage (" void *x;");
1070  output_storage (" unsigned short n;");
1071 
1072  output_storage (" x = &n;");
1073  output_storage (" optim_memcpy (x, p, 2);");
1074  output_storage (" n -= val;");
1075  output_storage (" optim_memcpy (p, x, 2);");
1076 #endif
1077  output_storage ("}");
1078  return;
1079 
1080  case COB_SUB_S16:
1081  output_storage ("static COB_INLINE COB_A_INLINE void");
1082  output_storage ("cob_sub_s16 (void *p, const int val)");
1083  output_storage ("{");
1084 #ifdef COB_ALLOW_UNALIGNED
1085  output_storage (" *(short __unaligned *)p -= val;");
1086 #else
1087  output_storage (" void *x;");
1088  output_storage (" short n;");
1089 
1090  output_storage (" x = &n;");
1091  output_storage (" optim_memcpy (x, p, 2);");
1092  output_storage (" n -= val;");
1093  output_storage (" optim_memcpy (p, x, 2);");
1094 #endif
1095  output_storage ("}");
1096  return;
1097 
1098  case COB_SUB_U24:
1099  output_storage ("static COB_INLINE COB_A_INLINE void");
1100  output_storage ("cob_sub_u24 (void *p, const int val)");
1101  output_storage ("{");
1102  output_storage (" unsigned char *x;");
1103  output_storage (" unsigned int n = 0;");
1104 
1105 #ifdef WORDS_BIGENDIAN
1106  output_storage (" x = ((unsigned char *)&n) + 1;");
1107 #else
1108  output_storage (" x = (unsigned char *)&n;");
1109 #endif
1110  output_storage (" optim_memcpy (x, p, 3);");
1111  output_storage (" n -= val;");
1112  output_storage (" optim_memcpy (p, x, 3);");
1113  output_storage ("}");
1114  return;
1115 
1116  case COB_SUB_S24:
1117  output_storage ("static COB_INLINE COB_A_INLINE void");
1118  output_storage ("cob_sub_s24 (void *p, const int val)");
1119  output_storage ("{");
1120  output_storage (" unsigned char *x;");
1121  output_storage (" int n = 0;");
1122 
1123 #ifdef WORDS_BIGENDIAN
1124  output_storage (" x = (unsigned char *)&n;");
1125 #else
1126  output_storage (" x = ((unsigned char *)&n) + 1;");
1127 #endif
1128  output_storage (" optim_memcpy (x, p, 3);");
1129  output_storage (" n >>= 8; /* Shift with sign */");
1130  output_storage (" n -= val;");
1131 #ifdef WORDS_BIGENDIAN
1132  output_storage (" x = ((unsigned char *)&n) + 1;");
1133 #else
1134  output_storage (" x = (unsigned char *)&n;");
1135 #endif
1136  output_storage (" optim_memcpy (p, x, 3);");
1137  output_storage ("}");
1138  return;
1139 
1140  case COB_SUB_U32:
1141  output_storage ("static COB_INLINE COB_A_INLINE void");
1142  output_storage ("cob_sub_u32 (void *p, const int val)");
1143  output_storage ("{");
1144 #ifdef COB_ALLOW_UNALIGNED
1145  output_storage (" *(unsigned int __unaligned *)p -= val;");
1146 #else
1147  output_storage (" void *x;");
1148  output_storage (" unsigned int n;");
1149 
1150  output_storage (" x = &n;");
1151  output_storage (" optim_memcpy (x, p, 4);");
1152  output_storage (" n -= val;");
1153  output_storage (" optim_memcpy (p, x, 4);");
1154 #endif
1155  output_storage ("}");
1156  return;
1157 
1158  case COB_SUB_S32:
1159  output_storage ("static COB_INLINE COB_A_INLINE void");
1160  output_storage ("cob_sub_s32 (void *p, const int val)");
1161  output_storage ("{");
1162 #ifdef COB_ALLOW_UNALIGNED
1163  output_storage (" *(int __unaligned *)p -= val;");
1164 #else
1165  output_storage (" void *x;");
1166  output_storage (" int n;");
1167 
1168  output_storage (" x = &n;");
1169  output_storage (" optim_memcpy (x, p, 4);");
1170  output_storage (" n -= val;");
1171  output_storage (" optim_memcpy (p, x, 4);");
1172 #endif
1173  output_storage ("}");
1174  return;
1175 
1176  case COB_SUB_U40:
1177  output_storage ("static COB_INLINE COB_A_INLINE void");
1178  output_storage ("cob_sub_u40 (void *p, const int val)");
1179  output_storage ("{");
1180  output_storage (" cob_u64_t n = 0;");
1181  output_storage (" unsigned char *x;");
1182 
1183 #ifdef WORDS_BIGENDIAN
1184  output_storage (" x = ((unsigned char *)&n) + 3;");
1185 #else
1186  output_storage (" x = (unsigned char *)&n;");
1187 #endif
1188  output_storage (" optim_memcpy (x, p, 5);");
1189  output_storage (" n -= val;");
1190  output_storage (" optim_memcpy (p, x, 5);");
1191  output_storage ("}");
1192  return;
1193 
1194  case COB_SUB_S40:
1195  output_storage ("static COB_INLINE COB_A_INLINE void");
1196  output_storage ("cob_sub_s40 (void *p, const int val)");
1197  output_storage ("{");
1198  output_storage (" cob_s64_t n = 0;");
1199  output_storage (" unsigned char *x;");
1200 
1201 #ifdef WORDS_BIGENDIAN
1202  output_storage (" x = (unsigned char *)&n;");
1203 #else
1204  output_storage (" x = ((unsigned char *)&n) + 3;");
1205 #endif
1206  output_storage (" optim_memcpy (x, p, 5);");
1207  output_storage (" n >>= 24; /* Shift with sign */");
1208  output_storage (" n -= val;");
1209 #ifdef WORDS_BIGENDIAN
1210  output_storage (" x = ((unsigned char *)&n) + 3;");
1211 #else
1212  output_storage (" x = (unsigned char *)&n;");
1213 #endif
1214  output_storage (" optim_memcpy (p, x, 5);");
1215  output_storage ("}");
1216  return;
1217 
1218  case COB_SUB_U48:
1219  output_storage ("static COB_INLINE COB_A_INLINE void");
1220  output_storage ("cob_sub_u48 (void *p, const int val)");
1221  output_storage ("{");
1222  output_storage (" cob_u64_t n = 0;");
1223  output_storage (" unsigned char *x;");
1224 
1225 #ifdef WORDS_BIGENDIAN
1226  output_storage (" x = ((unsigned char *)&n) + 2;");
1227 #else
1228  output_storage (" x = (unsigned char *)&n;");
1229 #endif
1230  output_storage (" optim_memcpy (x, p, 6);");
1231  output_storage (" n -= val;");
1232  output_storage (" optim_memcpy (p, x, 6);");
1233  output_storage ("}");
1234  return;
1235 
1236  case COB_SUB_S48:
1237  output_storage ("static COB_INLINE COB_A_INLINE void");
1238  output_storage ("cob_sub_s48 (void *p, const int val)");
1239  output_storage ("{");
1240  output_storage (" cob_s64_t n = 0;");
1241  output_storage (" unsigned char *x;");
1242 
1243 #ifdef WORDS_BIGENDIAN
1244  output_storage (" x = (unsigned char *)&n;");
1245 #else
1246  output_storage (" x = ((unsigned char *)&n) + 2;");
1247 #endif
1248  output_storage (" optim_memcpy (x, p, 6);");
1249  output_storage (" n >>= 16; /* Shift with sign */");
1250  output_storage (" n -= val;");
1251 #ifdef WORDS_BIGENDIAN
1252  output_storage (" x = ((unsigned char *)&n) + 2;");
1253 #else
1254  output_storage (" x = (unsigned char *)&n;");
1255 #endif
1256  output_storage (" optim_memcpy (p, x, 6);");
1257  output_storage ("}");
1258  return;
1259 
1260  case COB_SUB_U56:
1261  output_storage ("static COB_INLINE COB_A_INLINE void");
1262  output_storage ("cob_sub_u56 (void *p, const int val)");
1263  output_storage ("{");
1264  output_storage (" cob_u64_t n = 0;");
1265  output_storage (" unsigned char *x;");
1266 
1267 #ifdef WORDS_BIGENDIAN
1268  output_storage (" x = ((unsigned char *)&n) + 1;");
1269 #else
1270  output_storage (" x = (unsigned char *)&n;");
1271 #endif
1272  output_storage (" optim_memcpy (x, p, 7);");
1273  output_storage (" n -= val;");
1274  output_storage (" optim_memcpy (p, x, 7);");
1275  output_storage ("}");
1276  return;
1277 
1278  case COB_SUB_S56:
1279  output_storage ("static COB_INLINE COB_A_INLINE void");
1280  output_storage ("cob_sub_s56 (void *p, const int val)");
1281  output_storage ("{");
1282  output_storage (" cob_s64_t n = 0;");
1283  output_storage (" unsigned char *x;");
1284 
1285 #ifdef WORDS_BIGENDIAN
1286  output_storage (" x = (unsigned char *)&n;");
1287 #else
1288  output_storage (" x = ((unsigned char *)&n) + 1;");
1289 #endif
1290  output_storage (" optim_memcpy (x, p, 7);");
1291  output_storage (" n >>= 8; /* Shift with sign */");
1292  output_storage (" n -= val;");
1293 #ifdef WORDS_BIGENDIAN
1294  output_storage (" x = ((unsigned char *)&n) + 1;");
1295 #else
1296  output_storage (" x = (unsigned char *)&n;");
1297 #endif
1298  output_storage (" optim_memcpy (p, x, 7);");
1299  output_storage ("}");
1300  return;
1301 
1302  case COB_SUB_U64:
1303  output_storage ("static COB_INLINE COB_A_INLINE void");
1304  output_storage ("cob_sub_u64 (void *p, const int val)");
1305  output_storage ("{");
1306 #ifdef COB_ALLOW_UNALIGNED
1307  output_storage (" *(cob_u64_t __unaligned *)p -= val;");
1308 #else
1309  output_storage (" void *x;");
1310  output_storage (" cob_u64_t n;");
1311 
1312  output_storage (" x = &n;");
1313  output_storage (" optim_memcpy (x, p, 8);");
1314  output_storage (" n -= val;");
1315  output_storage (" optim_memcpy (p, x, 8);");
1316 #endif
1317  output_storage ("}");
1318  return;
1319 
1320  case COB_SUB_S64:
1321  output_storage ("static COB_INLINE COB_A_INLINE void");
1322  output_storage ("cob_sub_s64 (void *p, const int val)");
1323  output_storage ("{");
1324 #ifdef COB_ALLOW_UNALIGNED
1325  output_storage (" *(cob_s64_t __unaligned *)p -= val;");
1326 #else
1327  output_storage (" void *x;");
1328  output_storage (" cob_s64_t n;");
1329 
1330  output_storage (" x = &n;");
1331  output_storage (" optim_memcpy (x, p, 8);");
1332  output_storage (" n -= val;");
1333  output_storage (" optim_memcpy (p, x, 8);");
1334 #endif
1335  output_storage ("}");
1336  return;
1337 
1338  /* Binary swapped compare */
1339 
1340  case COB_CMPSWP_U16:
1341  output_storage ("static COB_INLINE COB_A_INLINE int");
1342  output_storage ("cob_cmpswp_u16 (const void *p, const cob_s64_t n)");
1343  output_storage ("{");
1344 #ifndef COB_ALLOW_UNALIGNED
1345  output_storage (" void *x;");
1346 #endif
1347  output_storage (" unsigned short val;");
1348 
1349  output_storage (" if (unlikely(n < 0)) {");
1350  output_storage (" return 1;");
1351  output_storage (" }");
1352 #ifdef COB_ALLOW_UNALIGNED
1353  output_storage (" val = COB_BSWAP_16 (*(unsigned short __unaligned *)p);");
1354 #else
1355  output_storage (" x = &val;");
1356  output_storage (" optim_memcpy (x, p, 2);");
1357  output_storage (" val = COB_BSWAP_16 (val);");
1358 #endif
1359  output_storage (" return (val < n) ? -1 : (val > n);");
1360  output_storage ("}");
1361  return;
1362 
1363  case COB_CMPSWP_S16:
1364  output_storage ("static COB_INLINE COB_A_INLINE int");
1365  output_storage ("cob_cmpswp_s16 (const void *p, const cob_s64_t n)");
1366  output_storage ("{");
1367  output_storage (" short val;");
1368 
1369 #ifdef COB_ALLOW_UNALIGNED
1370  output_storage (" val = COB_BSWAP_16 (*(short __unaligned *)p);");
1371 #else
1372  output_storage (" void *x;");
1373 
1374  output_storage (" x = &val;");
1375  output_storage (" optim_memcpy (x, p, 2);");
1376  output_storage (" val = COB_BSWAP_16 (val);");
1377 #endif
1378  output_storage (" return (val < n) ? -1 : (val > n);");
1379  output_storage ("}");
1380  return;
1381 
1382  case COB_CMPSWP_U24:
1383  output_storage ("static COB_INLINE COB_A_INLINE int");
1384  output_storage ("cob_cmpswp_u24 (const void *p, const cob_s64_t n)");
1385  output_storage ("{");
1386  output_storage (" unsigned char *x;");
1387  output_storage (" unsigned int val = 0;");
1388 
1389  output_storage (" if (unlikely(n < 0)) {");
1390  output_storage (" return 1;");
1391  output_storage (" }");
1392  output_storage (" x = ((unsigned char *)&val) + 1;");
1393  output_storage (" optim_memcpy (x, p, 3);");
1394  output_storage (" val = COB_BSWAP_32 (val);");
1395  output_storage (" return (val < n) ? -1 : (val > n);");
1396  output_storage ("}");
1397  return;
1398 
1399  case COB_CMPSWP_S24:
1400  output_storage ("static COB_INLINE COB_A_INLINE int");
1401  output_storage ("cob_cmpswp_s24 (const void *p, const cob_s64_t n)");
1402  output_storage ("{");
1403  output_storage (" unsigned char *x;");
1404  output_storage (" int val = 0;");
1405 
1406  output_storage (" x = (unsigned char *)&val;");
1407  output_storage (" optim_memcpy (x, p, 3);");
1408  output_storage (" val = COB_BSWAP_32 (val);");
1409  output_storage (" val >>= 8; /* Shift with sign */");
1410  output_storage (" return (val < n) ? -1 : (val > n);");
1411  output_storage ("}");
1412  return;
1413 
1414  case COB_CMPSWP_U32:
1415  output_storage ("static COB_INLINE COB_A_INLINE int");
1416  output_storage ("cob_cmpswp_u32 (const void *p, const cob_s64_t n)");
1417  output_storage ("{");
1418 #ifndef COB_ALLOW_UNALIGNED
1419  output_storage (" void *x;");
1420 #endif
1421  output_storage (" unsigned int val;");
1422 
1423  output_storage (" if (unlikely(n < 0)) {");
1424  output_storage (" return 1;");
1425  output_storage (" }");
1426 #ifdef COB_ALLOW_UNALIGNED
1427  output_storage (" val = COB_BSWAP_32 (*(const unsigned int __unaligned *)p);");
1428 #else
1429  output_storage (" x = &val;");
1430  output_storage (" optim_memcpy (x, p, 4);");
1431  output_storage (" val = COB_BSWAP_32 (val);");
1432 #endif
1433  output_storage (" return (val < n) ? -1 : (val > n);");
1434  output_storage ("}");
1435  return;
1436 
1437  case COB_CMPSWP_S32:
1438  output_storage ("static COB_INLINE COB_A_INLINE int");
1439  output_storage ("cob_cmpswp_s32 (const void *p, const cob_s64_t n)");
1440  output_storage ("{");
1441  output_storage (" int val;");
1442 
1443 #ifdef COB_ALLOW_UNALIGNED
1444  output_storage (" val = COB_BSWAP_32 (*(const int __unaligned *)p);");
1445 #else
1446  output_storage (" void *x;");
1447 
1448  output_storage (" x = &val;");
1449  output_storage (" optim_memcpy (x, p, 4);");
1450  output_storage (" val = COB_BSWAP_32 (val);");
1451 #endif
1452  output_storage (" return (val < n) ? -1 : (val > n);");
1453  output_storage ("}");
1454  return;
1455 
1456  case COB_CMPSWP_U40:
1457  output_storage ("static COB_INLINE COB_A_INLINE int");
1458  output_storage ("cob_cmpswp_u40 (const void *p, const cob_s64_t n)");
1459  output_storage ("{");
1460  output_storage (" cob_u64_t val = 0;");
1461  output_storage (" unsigned char *x;");
1462 
1463  output_storage (" if (unlikely(n < 0)) {");
1464  output_storage (" return 1;");
1465  output_storage (" }");
1466  output_storage (" x = ((unsigned char *)&val) + 3;");
1467  output_storage (" optim_memcpy (x, p, 5);");
1468  output_storage (" val = COB_BSWAP_64 (val);");
1469  output_storage (" return (val < n) ? -1 : (val > n);");
1470  output_storage ("}");
1471  return;
1472 
1473  case COB_CMPSWP_S40:
1474  output_storage ("static COB_INLINE COB_A_INLINE int");
1475  output_storage ("cob_cmpswp_s40 (const void *p, const cob_s64_t n)");
1476  output_storage ("{");
1477  output_storage (" cob_s64_t val = 0;");
1478  output_storage (" unsigned char *x;");
1479 
1480  output_storage (" x = (unsigned char *)&val;");
1481  output_storage (" optim_memcpy (x, p, 5);");
1482  output_storage (" val = COB_BSWAP_64 (val);");
1483  output_storage (" val >>= 24; /* Shift with sign */");
1484  output_storage (" return (val < n) ? -1 : (val > n);");
1485  output_storage ("}");
1486  return;
1487 
1488  case COB_CMPSWP_U48:
1489  output_storage ("static COB_INLINE COB_A_INLINE int");
1490  output_storage ("cob_cmpswp_u48 (const void *p, const cob_s64_t n)");
1491  output_storage ("{");
1492  output_storage (" cob_u64_t val = 0;");
1493  output_storage (" unsigned char *x;");
1494 
1495  output_storage (" if (unlikely(n < 0)) {");
1496  output_storage (" return 1;");
1497  output_storage (" }");
1498  output_storage (" x = ((unsigned char *)&val) + 2;");
1499  output_storage (" optim_memcpy (x, p, 6);");
1500  output_storage (" val = COB_BSWAP_64 (val);");
1501  output_storage (" return (val < n) ? -1 : (val > n);");
1502  output_storage ("}");
1503  return;
1504 
1505  case COB_CMPSWP_S48:
1506  output_storage ("static COB_INLINE COB_A_INLINE int");
1507  output_storage ("cob_cmpswp_s48 (const void *p, const cob_s64_t n)");
1508  output_storage ("{");
1509  output_storage (" cob_s64_t val = 0;");
1510  output_storage (" unsigned char *x;");
1511 
1512  output_storage (" x = (unsigned char *)&val;");
1513  output_storage (" optim_memcpy (x, p, 6);");
1514  output_storage (" val = COB_BSWAP_64 (val);");
1515  output_storage (" val >>= 16; /* Shift with sign */");
1516  output_storage (" return (val < n) ? -1 : (val > n);");
1517  output_storage ("}");
1518  return;
1519 
1520  case COB_CMPSWP_U56:
1521  output_storage ("static COB_INLINE COB_A_INLINE int");
1522  output_storage ("cob_cmpswp_u56 (const void *p, const cob_s64_t n)");
1523  output_storage ("{");
1524  output_storage (" cob_u64_t val = 0;");
1525  output_storage (" unsigned char *x;");
1526 
1527  output_storage (" if (unlikely(n < 0)) {");
1528  output_storage (" return 1;");
1529  output_storage (" }");
1530  output_storage (" x = ((unsigned char *)&val) + 1;");
1531  output_storage (" optim_memcpy (x, p, 7);");
1532  output_storage (" val = COB_BSWAP_64 (val);");
1533  output_storage (" return (val < n) ? -1 : (val > n);");
1534  output_storage ("}");
1535  return;
1536 
1537  case COB_CMPSWP_S56:
1538  output_storage ("static COB_INLINE COB_A_INLINE int");
1539  output_storage ("cob_cmpswp_s56 (const void *p, const cob_s64_t n)");
1540  output_storage ("{");
1541  output_storage (" cob_s64_t val = 0;");
1542  output_storage (" unsigned char *x;");
1543 
1544  output_storage (" x = (unsigned char *)&val;");
1545  output_storage (" optim_memcpy (x, p, 7);");
1546  output_storage (" val = COB_BSWAP_64 (val);");
1547  output_storage (" val >>= 8; /* Shift with sign */");
1548  output_storage (" return (val < n) ? -1 : (val > n);");
1549  output_storage ("}");
1550  return;
1551 
1552  case COB_CMPSWP_U64:
1553  output_storage ("static COB_INLINE COB_A_INLINE int");
1554  output_storage ("cob_cmpswp_u64 (const void *p, const cob_s64_t n)");
1555  output_storage ("{");
1556 #ifndef COB_ALLOW_UNALIGNED
1557  output_storage (" void *x;");
1558 #endif
1559  output_storage (" cob_u64_t val;");
1560 
1561  output_storage (" if (unlikely(n < 0)) {");
1562  output_storage (" return 1;");
1563  output_storage (" }");
1564 #ifdef COB_ALLOW_UNALIGNED
1565  output_storage (" val = COB_BSWAP_64 (*(const cob_u64_t __unaligned *)p);");
1566 #else
1567  output_storage (" x = &val;");
1568  output_storage (" optim_memcpy (x, p, 8);");
1569  output_storage (" val = COB_BSWAP_64 (val);");
1570 #endif
1571  output_storage (" return (val < n) ? -1 : (val > n);");
1572  output_storage ("}");
1573  return;
1574 
1575  case COB_CMPSWP_S64:
1576  output_storage ("static COB_INLINE COB_A_INLINE int");
1577  output_storage ("cob_cmpswp_s64 (const void *p, const cob_s64_t n)");
1578  output_storage ("{");
1579  output_storage (" cob_s64_t val;");
1580 
1581 #ifdef COB_ALLOW_UNALIGNED
1582  output_storage (" val = COB_BSWAP_64 (*(const cob_s64_t __unaligned *)p);");
1583 #else
1584  output_storage (" void *x;");
1585  output_storage (" x = &val;");
1586  output_storage (" optim_memcpy (x, p, 8);");
1587  output_storage (" val = COB_BSWAP_64 (val);");
1588 #endif
1589  output_storage (" return (val < n) ? -1 : (val > n);");
1590  output_storage ("}");
1591  return;
1592 
1593  /* Binary swapped add */
1594 
1595  case COB_ADDSWP_U16:
1596  output_storage ("static COB_INLINE COB_A_INLINE void");
1597  output_storage ("cob_addswp_u16 (void *p, const int val)");
1598  output_storage ("{");
1599  output_storage (" unsigned short n;");
1600 
1601 #ifdef COB_ALLOW_UNALIGNED
1602  output_storage (" n = COB_BSWAP_16 (*(unsigned short __unaligned *)p);");
1603  output_storage (" n += val;");
1604  output_storage (" *(unsigned short __unaligned *)p = COB_BSWAP_16(n);");
1605 #else
1606  output_storage (" unsigned char *x;");
1607  output_storage (" unsigned char *px = p;");
1608 
1609  output_storage (" x = (unsigned char *)&n;");
1610  output_storage (" x[0] = px[1];");
1611  output_storage (" x[1] = px[0];");
1612  output_storage (" n += val;");
1613  output_storage (" px[0] = x[1];");
1614  output_storage (" px[1] = x[0];");
1615 #endif
1616  output_storage ("}");
1617  return;
1618 
1619  case COB_ADDSWP_S16:
1620  output_storage ("static COB_INLINE COB_A_INLINE void");
1621  output_storage ("cob_addswp_s16 (void *p, const int val)");
1622  output_storage ("{");
1623  output_storage (" short n;");
1624 
1625 #ifdef COB_ALLOW_UNALIGNED
1626  output_storage (" n = COB_BSWAP_16 (*(short __unaligned *)p);");
1627  output_storage (" n += val;");
1628  output_storage (" *(short __unaligned *)p = COB_BSWAP_16(n);");
1629 #else
1630  output_storage (" unsigned char *x;");
1631  output_storage (" unsigned char *px = p;");
1632 
1633  output_storage (" x = (unsigned char *)&n;");
1634  output_storage (" x[0] = px[1];");
1635  output_storage (" x[1] = px[0];");
1636  output_storage (" n += val;");
1637  output_storage (" px[0] = x[1];");
1638  output_storage (" px[1] = x[0];");
1639 #endif
1640  output_storage ("}");
1641  return;
1642 
1643  case COB_ADDSWP_U24:
1644  output_storage ("static COB_INLINE COB_A_INLINE void");
1645  output_storage ("cob_addswp_u24 (void *p, const int val)");
1646  output_storage ("{");
1647  output_storage (" unsigned char *x;");
1648  output_storage (" unsigned char *px = p;");
1649  output_storage (" unsigned int n = 0;");
1650 
1651  output_storage (" x = (unsigned char *)&n;");
1652  output_storage (" x[0] = px[2];");
1653  output_storage (" x[1] = px[1];");
1654  output_storage (" x[2] = px[0];");
1655  output_storage (" n += val;");
1656  output_storage (" px[0] = x[2];");
1657  output_storage (" px[1] = x[1];");
1658  output_storage (" px[2] = x[0];");
1659  output_storage ("}");
1660  return;
1661 
1662  case COB_ADDSWP_S24:
1663  output_storage ("static COB_INLINE COB_A_INLINE void");
1664  output_storage ("cob_addswp_s24 (void *p, const int val)");
1665  output_storage ("{");
1666  output_storage (" unsigned char *x;");
1667  output_storage (" unsigned char *px = p;");
1668  output_storage (" int n = 0;");
1669 
1670  output_storage (" x = ((unsigned char *)&n) + 1;");
1671  output_storage (" x[0] = px[2];");
1672  output_storage (" x[1] = px[1];");
1673  output_storage (" x[2] = px[0];");
1674  output_storage (" n >>= 8; /* Shift with sign */");
1675  output_storage (" n += val;");
1676  output_storage (" x = (unsigned char *)&n;");
1677  output_storage (" px[0] = x[2];");
1678  output_storage (" px[1] = x[1];");
1679  output_storage (" px[2] = x[0];");
1680  output_storage ("}");
1681  return;
1682 
1683  case COB_ADDSWP_U32:
1684  output_storage ("static COB_INLINE COB_A_INLINE void");
1685  output_storage ("cob_addswp_u32 (void *p, const int val)");
1686  output_storage ("{");
1687  output_storage (" unsigned int n;");
1688 
1689 #ifdef COB_ALLOW_UNALIGNED
1690  output_storage (" n = COB_BSWAP_32 (*(unsigned int __unaligned *)p);");
1691  output_storage (" n += val;");
1692  output_storage (" *(unsigned int __unaligned *)p = COB_BSWAP_32(n);");
1693 #else
1694  output_storage (" unsigned char *x;");
1695  output_storage (" unsigned char *px = p;");
1696 
1697  output_storage (" x = (unsigned char *)&n;");
1698  output_storage (" x[0] = px[3];");
1699  output_storage (" x[1] = px[2];");
1700  output_storage (" x[2] = px[1];");
1701  output_storage (" x[3] = px[0];");
1702  output_storage (" n += val;");
1703  output_storage (" px[0] = x[3];");
1704  output_storage (" px[1] = x[2];");
1705  output_storage (" px[2] = x[1];");
1706  output_storage (" px[3] = x[0];");
1707 #endif
1708  output_storage ("}");
1709  return;
1710 
1711  case COB_ADDSWP_S32:
1712  output_storage ("static COB_INLINE COB_A_INLINE void");
1713  output_storage ("cob_addswp_s32 (void *p, const int val)");
1714  output_storage ("{");
1715  output_storage (" int n;");
1716 
1717 #ifdef COB_ALLOW_UNALIGNED
1718  output_storage (" n = COB_BSWAP_32 (*(int __unaligned *)p);");
1719  output_storage (" n += val;");
1720  output_storage (" *(int __unaligned *)p = COB_BSWAP_32(n);");
1721 #else
1722  output_storage (" unsigned char *x;");
1723  output_storage (" unsigned char *px = p;");
1724 
1725  output_storage (" x = (unsigned char *)&n;");
1726  output_storage (" x[0] = px[3];");
1727  output_storage (" x[1] = px[2];");
1728  output_storage (" x[2] = px[1];");
1729  output_storage (" x[3] = px[0];");
1730  output_storage (" n += val;");
1731  output_storage (" px[0] = x[3];");
1732  output_storage (" px[1] = x[2];");
1733  output_storage (" px[2] = x[1];");
1734  output_storage (" px[3] = x[0];");
1735 #endif
1736  output_storage ("}");
1737  return;
1738 
1739  case COB_ADDSWP_U40:
1740  output_storage ("static COB_INLINE COB_A_INLINE void");
1741  output_storage ("cob_addswp_u40 (void *p, const int val)");
1742  output_storage ("{");
1743  output_storage (" cob_u64_t n = 0;");
1744  output_storage (" unsigned char *x;");
1745  output_storage (" unsigned char *px = p;");
1746 
1747  output_storage (" x = (unsigned char *)&n;");
1748  output_storage (" x[0] = px[4];");
1749  output_storage (" x[1] = px[3];");
1750  output_storage (" x[2] = px[2];");
1751  output_storage (" x[3] = px[1];");
1752  output_storage (" x[4] = px[0];");
1753  output_storage (" n += val;");
1754  output_storage (" px[0] = x[4];");
1755  output_storage (" px[1] = x[3];");
1756  output_storage (" px[2] = x[2];");
1757  output_storage (" px[3] = x[1];");
1758  output_storage (" px[4] = x[0];");
1759  output_storage ("}");
1760  return;
1761 
1762  case COB_ADDSWP_S40:
1763  output_storage ("static COB_INLINE COB_A_INLINE void");
1764  output_storage ("cob_addswp_s40 (void *p, const int val)");
1765  output_storage ("{");
1766  output_storage (" cob_s64_t n = 0;");
1767  output_storage (" unsigned char *x;");
1768  output_storage (" unsigned char *px = p;");
1769 
1770  output_storage (" x = ((unsigned char *)&n) + 3;");
1771  output_storage (" x[0] = px[4];");
1772  output_storage (" x[1] = px[3];");
1773  output_storage (" x[2] = px[2];");
1774  output_storage (" x[3] = px[1];");
1775  output_storage (" x[4] = px[0];");
1776  output_storage (" n >>= 24; /* Shift with sign */");
1777  output_storage (" n += val;");
1778  output_storage (" x = (unsigned char *)&n;");
1779  output_storage (" px[0] = x[4];");
1780  output_storage (" px[1] = x[3];");
1781  output_storage (" px[2] = x[2];");
1782  output_storage (" px[3] = x[1];");
1783  output_storage (" px[4] = x[0];");
1784  output_storage ("}");
1785  return;
1786 
1787  case COB_ADDSWP_U48:
1788  output_storage ("static COB_INLINE COB_A_INLINE void");
1789  output_storage ("cob_addswp_u48 (void *p, const int val)");
1790  output_storage ("{");
1791  output_storage (" cob_u64_t n = 0;");
1792  output_storage (" unsigned char *x;");
1793  output_storage (" unsigned char *px = p;");
1794 
1795  output_storage (" x = (unsigned char *)&n;");
1796  output_storage (" x[0] = px[5];");
1797  output_storage (" x[1] = px[4];");
1798  output_storage (" x[2] = px[3];");
1799  output_storage (" x[3] = px[2];");
1800  output_storage (" x[4] = px[1];");
1801  output_storage (" x[5] = px[0];");
1802  output_storage (" n += val;");
1803  output_storage (" px[0] = x[5];");
1804  output_storage (" px[1] = x[4];");
1805  output_storage (" px[2] = x[3];");
1806  output_storage (" px[3] = x[2];");
1807  output_storage (" px[4] = x[1];");
1808  output_storage (" px[5] = x[0];");
1809  output_storage ("}");
1810  return;
1811 
1812  case COB_ADDSWP_S48:
1813  output_storage ("static COB_INLINE COB_A_INLINE void");
1814  output_storage ("cob_addswp_s48 (void *p, const int val)");
1815  output_storage ("{");
1816  output_storage (" cob_s64_t n = 0;");
1817  output_storage (" unsigned char *x;");
1818  output_storage (" unsigned char *px = p;");
1819 
1820  output_storage (" x = ((unsigned char *)&n) + 2;");
1821  output_storage (" x[0] = px[5];");
1822  output_storage (" x[1] = px[4];");
1823  output_storage (" x[2] = px[3];");
1824  output_storage (" x[3] = px[2];");
1825  output_storage (" x[4] = px[1];");
1826  output_storage (" x[5] = px[0];");
1827  output_storage (" n >>= 16; /* Shift with sign */");
1828  output_storage (" n += val;");
1829  output_storage (" x = (unsigned char *)&n;");
1830  output_storage (" px[0] = x[5];");
1831  output_storage (" px[1] = x[4];");
1832  output_storage (" px[2] = x[3];");
1833  output_storage (" px[3] = x[2];");
1834  output_storage (" px[4] = x[1];");
1835  output_storage (" px[5] = x[0];");
1836  output_storage ("}");
1837  return;
1838 
1839  case COB_ADDSWP_U56:
1840  output_storage ("static COB_INLINE COB_A_INLINE void");
1841  output_storage ("cob_addswp_u56 (void *p, const int val)");
1842  output_storage ("{");
1843  output_storage (" cob_u64_t n = 0;");
1844  output_storage (" unsigned char *x;");
1845  output_storage (" unsigned char *px = p;");
1846 
1847  output_storage (" x = (unsigned char *)&n;");
1848  output_storage (" x[0] = px[6];");
1849  output_storage (" x[1] = px[5];");
1850  output_storage (" x[2] = px[4];");
1851  output_storage (" x[3] = px[3];");
1852  output_storage (" x[4] = px[2];");
1853  output_storage (" x[5] = px[1];");
1854  output_storage (" x[6] = px[0];");
1855  output_storage (" n += val;");
1856  output_storage (" px[0] = x[6];");
1857  output_storage (" px[1] = x[5];");
1858  output_storage (" px[2] = x[4];");
1859  output_storage (" px[3] = x[3];");
1860  output_storage (" px[4] = x[2];");
1861  output_storage (" px[5] = x[1];");
1862  output_storage (" px[6] = x[0];");
1863  output_storage ("}");
1864  return;
1865 
1866  case COB_ADDSWP_S56:
1867  output_storage ("static COB_INLINE COB_A_INLINE void");
1868  output_storage ("cob_addswp_s56 (void *p, const int val)");
1869  output_storage ("{");
1870  output_storage (" cob_s64_t n = 0;");
1871  output_storage (" unsigned char *x;");
1872  output_storage (" unsigned char *px = p;");
1873 
1874  output_storage (" x = ((unsigned char *)&n) + 1;");
1875  output_storage (" x[0] = px[6];");
1876  output_storage (" x[1] = px[5];");
1877  output_storage (" x[2] = px[4];");
1878  output_storage (" x[3] = px[3];");
1879  output_storage (" x[4] = px[2];");
1880  output_storage (" x[5] = px[1];");
1881  output_storage (" x[6] = px[0];");
1882  output_storage (" n >>= 8; /* Shift with sign */");
1883  output_storage (" n += val;");
1884  output_storage (" x = (unsigned char *)&n;");
1885  output_storage (" px[0] = x[6];");
1886  output_storage (" px[1] = x[5];");
1887  output_storage (" px[2] = x[4];");
1888  output_storage (" px[3] = x[3];");
1889  output_storage (" px[4] = x[2];");
1890  output_storage (" px[5] = x[1];");
1891  output_storage (" px[6] = x[0];");
1892  output_storage ("}");
1893  return;
1894 
1895  case COB_ADDSWP_U64:
1896  output_storage ("static COB_INLINE COB_A_INLINE void");
1897  output_storage ("cob_addswp_u64 (void *p, const int val)");
1898  output_storage ("{");
1899  output_storage (" cob_u64_t n;");
1900 
1901 #ifdef COB_ALLOW_UNALIGNED
1902  output_storage (" n = COB_BSWAP_64 (*(cob_u64_t __unaligned *)p);");
1903  output_storage (" n += val;");
1904  output_storage (" *(cob_u64_t __unaligned *)p = COB_BSWAP_64(n);");
1905 #else
1906  output_storage (" unsigned char *x;");
1907  output_storage (" unsigned char *px = p;");
1908 
1909  output_storage (" x = (unsigned char *)&n;");
1910  output_storage (" x[0] = px[7];");
1911  output_storage (" x[1] = px[6];");
1912  output_storage (" x[2] = px[5];");
1913  output_storage (" x[3] = px[4];");
1914  output_storage (" x[4] = px[3];");
1915  output_storage (" x[5] = px[2];");
1916  output_storage (" x[6] = px[1];");
1917  output_storage (" x[7] = px[0];");
1918  output_storage (" n += val;");
1919  output_storage (" px[0] = x[7];");
1920  output_storage (" px[1] = x[6];");
1921  output_storage (" px[2] = x[5];");
1922  output_storage (" px[3] = x[4];");
1923  output_storage (" px[4] = x[3];");
1924  output_storage (" px[5] = x[2];");
1925  output_storage (" px[6] = x[1];");
1926  output_storage (" px[7] = x[0];");
1927 #endif
1928  output_storage ("}");
1929  return;
1930 
1931  case COB_ADDSWP_S64:
1932  output_storage ("static COB_INLINE COB_A_INLINE void");
1933  output_storage ("cob_addswp_s64 (void *p, const int val)");
1934  output_storage ("{");
1935  output_storage (" cob_s64_t n;");
1936 
1937 #ifdef COB_ALLOW_UNALIGNED
1938  output_storage (" n = COB_BSWAP_64 (*(cob_s64_t __unaligned *)p);");
1939  output_storage (" n += val;");
1940  output_storage (" *(cob_s64_t __unaligned *)p = COB_BSWAP_64(n);");
1941 #else
1942  output_storage (" unsigned char *x;");
1943  output_storage (" unsigned char *px = p;");
1944 
1945  output_storage (" x = (unsigned char *)&n;");
1946  output_storage (" x[0] = px[7];");
1947  output_storage (" x[1] = px[6];");
1948  output_storage (" x[2] = px[5];");
1949  output_storage (" x[3] = px[4];");
1950  output_storage (" x[4] = px[3];");
1951  output_storage (" x[5] = px[2];");
1952  output_storage (" x[6] = px[1];");
1953  output_storage (" x[7] = px[0];");
1954  output_storage (" n += val;");
1955  output_storage (" px[0] = x[7];");
1956  output_storage (" px[1] = x[6];");
1957  output_storage (" px[2] = x[5];");
1958  output_storage (" px[3] = x[4];");
1959  output_storage (" px[4] = x[3];");
1960  output_storage (" px[5] = x[2];");
1961  output_storage (" px[6] = x[1];");
1962  output_storage (" px[7] = x[0];");
1963 #endif
1964  output_storage ("}");
1965  return;
1966 
1967  /* Binary swapped subtract */
1968 
1969  case COB_SUBSWP_U16:
1970  output_storage ("static COB_INLINE COB_A_INLINE void");
1971  output_storage ("cob_subswp_u16 (void *p, const int val)");
1972  output_storage ("{");
1973  output_storage (" unsigned short n;");
1974 
1975 #ifdef COB_ALLOW_UNALIGNED
1976  output_storage (" n = COB_BSWAP_16 (*(unsigned short __unaligned *)p);");
1977  output_storage (" n -= val;");
1978  output_storage (" *(unsigned short __unaligned *)p = COB_BSWAP_16(n);");
1979 #else
1980  output_storage (" unsigned char *x;");
1981  output_storage (" unsigned char *px = p;");
1982 
1983  output_storage (" x = (unsigned char *)&n;");
1984  output_storage (" x[0] = px[1];");
1985  output_storage (" x[1] = px[0];");
1986  output_storage (" n -= val;");
1987  output_storage (" px[0] = x[1];");
1988  output_storage (" px[1] = x[0];");
1989 #endif
1990  output_storage ("}");
1991  return;
1992 
1993  case COB_SUBSWP_S16:
1994  output_storage ("static COB_INLINE COB_A_INLINE void");
1995  output_storage ("cob_subswp_s16 (void *p, const int val)");
1996  output_storage ("{");
1997  output_storage (" short n;");
1998 
1999 #ifdef COB_ALLOW_UNALIGNED
2000  output_storage (" n = COB_BSWAP_16 (*(short __unaligned *)p);");
2001  output_storage (" n -= val;");
2002  output_storage (" *(short __unaligned *)p = COB_BSWAP_16(n);");
2003 #else
2004  output_storage (" unsigned char *x;");
2005  output_storage (" unsigned char *px = p;");
2006 
2007  output_storage (" x = (unsigned char *)&n;");
2008  output_storage (" x[0] = px[1];");
2009  output_storage (" x[1] = px[0];");
2010  output_storage (" n -= val;");
2011  output_storage (" px[0] = x[1];");
2012  output_storage (" px[1] = x[0];");
2013 #endif
2014  output_storage ("}");
2015  return;
2016 
2017  case COB_SUBSWP_U24:
2018  output_storage ("static COB_INLINE COB_A_INLINE void");
2019  output_storage ("cob_subswp_u24 (void *p, const int val)");
2020  output_storage ("{");
2021  output_storage (" unsigned char *x;");
2022  output_storage (" unsigned char *px = p;");
2023  output_storage (" unsigned int n = 0;");
2024 
2025  output_storage (" x = (unsigned char *)&n;");
2026  output_storage (" x[0] = px[2];");
2027  output_storage (" x[1] = px[1];");
2028  output_storage (" x[2] = px[0];");
2029  output_storage (" n -= val;");
2030  output_storage (" px[0] = x[2];");
2031  output_storage (" px[1] = x[1];");
2032  output_storage (" px[2] = x[0];");
2033  output_storage ("}");
2034  return;
2035 
2036  case COB_SUBSWP_S24:
2037  output_storage ("static COB_INLINE COB_A_INLINE void");
2038  output_storage ("cob_subswp_s24 (void *p, const int val)");
2039  output_storage ("{");
2040  output_storage (" unsigned char *x;");
2041  output_storage (" unsigned char *px = p;");
2042  output_storage (" int n = 0;");
2043 
2044  output_storage (" x = ((unsigned char *)&n) + 1;");
2045  output_storage (" x[0] = px[2];");
2046  output_storage (" x[1] = px[1];");
2047  output_storage (" x[2] = px[0];");
2048  output_storage (" n >>= 8; /* Shift with sign */");
2049  output_storage (" n -= val;");
2050  output_storage (" x = (unsigned char *)&n;");
2051  output_storage (" px[0] = x[2];");
2052  output_storage (" px[1] = x[1];");
2053  output_storage (" px[2] = x[0];");
2054  output_storage ("}");
2055  return;
2056 
2057  case COB_SUBSWP_U32:
2058  output_storage ("static COB_INLINE COB_A_INLINE void");
2059  output_storage ("cob_subswp_u32 (void *p, const int val)");
2060  output_storage ("{");
2061  output_storage (" unsigned int n;");
2062 
2063 #ifdef COB_ALLOW_UNALIGNED
2064  output_storage (" n = COB_BSWAP_32 (*(unsigned int __unaligned *)p);");
2065  output_storage (" n -= val;");
2066  output_storage (" *(unsigned int __unaligned *)p = COB_BSWAP_32(n);");
2067 #else
2068  output_storage (" unsigned char *x;");
2069  output_storage (" unsigned char *px = p;");
2070 
2071  output_storage (" x = (unsigned char *)&n;");
2072  output_storage (" x[0] = px[3];");
2073  output_storage (" x[1] = px[2];");
2074  output_storage (" x[2] = px[1];");
2075  output_storage (" x[3] = px[0];");
2076  output_storage (" n -= val;");
2077  output_storage (" px[0] = x[3];");
2078  output_storage (" px[1] = x[2];");
2079  output_storage (" px[2] = x[1];");
2080  output_storage (" px[3] = x[0];");
2081 #endif
2082  output_storage ("}");
2083  return;
2084 
2085  case COB_SUBSWP_S32:
2086  output_storage ("static COB_INLINE COB_A_INLINE void");
2087  output_storage ("cob_subswp_s32 (void *p, const int val)");
2088  output_storage ("{");
2089  output_storage (" int n;");
2090 
2091 #ifdef COB_ALLOW_UNALIGNED
2092  output_storage (" n = COB_BSWAP_32 (*(int __unaligned *)p);");
2093  output_storage (" n -= val;");
2094  output_storage (" *(int __unaligned *)p = COB_BSWAP_32(n);");
2095 #else
2096  output_storage (" unsigned char *x;");
2097  output_storage (" unsigned char *px = p;");
2098 
2099  output_storage (" x = (unsigned char *)&n;");
2100  output_storage (" x[0] = px[3];");
2101  output_storage (" x[1] = px[2];");
2102  output_storage (" x[2] = px[1];");
2103  output_storage (" x[3] = px[0];");
2104  output_storage (" n -= val;");
2105  output_storage (" px[0] = x[3];");
2106  output_storage (" px[1] = x[2];");
2107  output_storage (" px[2] = x[1];");
2108  output_storage (" px[3] = x[0];");
2109 #endif
2110  output_storage ("}");
2111  return;
2112 
2113  case COB_SUBSWP_U40:
2114  output_storage ("static COB_INLINE COB_A_INLINE void");
2115  output_storage ("cob_subswp_u40 (void *p, const int val)");
2116  output_storage ("{");
2117  output_storage (" cob_u64_t n = 0;");
2118  output_storage (" unsigned char *x;");
2119  output_storage (" unsigned char *px = p;");
2120 
2121  output_storage (" x = (unsigned char *)&n;");
2122  output_storage (" x[0] = px[4];");
2123  output_storage (" x[1] = px[3];");
2124  output_storage (" x[2] = px[2];");
2125  output_storage (" x[3] = px[1];");
2126  output_storage (" x[4] = px[0];");
2127  output_storage (" n -= val;");
2128  output_storage (" px[0] = x[4];");
2129  output_storage (" px[1] = x[3];");
2130  output_storage (" px[2] = x[2];");
2131  output_storage (" px[3] = x[1];");
2132  output_storage (" px[4] = x[0];");
2133  output_storage ("}");
2134  return;
2135 
2136  case COB_SUBSWP_S40:
2137  output_storage ("static COB_INLINE COB_A_INLINE void");
2138  output_storage ("cob_subswp_s40 (void *p, const int val)");
2139  output_storage ("{");
2140  output_storage (" cob_s64_t n = 0;");
2141  output_storage (" unsigned char *x;");
2142  output_storage (" unsigned char *px = p;");
2143 
2144  output_storage (" x = ((unsigned char *)&n) + 3;");
2145  output_storage (" x[0] = px[4];");
2146  output_storage (" x[1] = px[3];");
2147  output_storage (" x[2] = px[2];");
2148  output_storage (" x[3] = px[1];");
2149  output_storage (" x[4] = px[0];");
2150  output_storage (" n >>= 24; /* Shift with sign */");
2151  output_storage (" n -= val;");
2152  output_storage (" x = (unsigned char *)&n;");
2153  output_storage (" px[0] = x[4];");
2154  output_storage (" px[1] = x[3];");
2155  output_storage (" px[2] = x[2];");
2156  output_storage (" px[3] = x[1];");
2157  output_storage (" px[4] = x[0];");
2158  output_storage ("}");
2159  return;
2160 
2161  case COB_SUBSWP_U48:
2162  output_storage ("static COB_INLINE COB_A_INLINE void");
2163  output_storage ("cob_subswp_u48 (void *p, const int val)");
2164  output_storage ("{");
2165  output_storage (" cob_u64_t n = 0;");
2166  output_storage (" unsigned char *x;");
2167  output_storage (" unsigned char *px = p;");
2168 
2169  output_storage (" x = (unsigned char *)&n;");
2170  output_storage (" x[0] = px[5];");
2171  output_storage (" x[1] = px[4];");
2172  output_storage (" x[2] = px[3];");
2173  output_storage (" x[3] = px[2];");
2174  output_storage (" x[4] = px[1];");
2175  output_storage (" x[5] = px[0];");
2176  output_storage (" n -= val;");
2177  output_storage (" px[0] = x[5];");
2178  output_storage (" px[1] = x[4];");
2179  output_storage (" px[2] = x[3];");
2180  output_storage (" px[3] = x[2];");
2181  output_storage (" px[4] = x[1];");
2182  output_storage (" px[5] = x[0];");
2183  output_storage ("}");
2184  return;
2185 
2186  case COB_SUBSWP_S48:
2187  output_storage ("static COB_INLINE COB_A_INLINE void");
2188  output_storage ("cob_subswp_s48 (void *p, const int val)");
2189  output_storage ("{");
2190  output_storage (" cob_s64_t n = 0;");
2191  output_storage (" unsigned char *x;");
2192  output_storage (" unsigned char *px = p;");
2193 
2194  output_storage (" x = ((unsigned char *)&n) + 2;");
2195  output_storage (" x[0] = px[5];");
2196  output_storage (" x[1] = px[4];");
2197  output_storage (" x[2] = px[3];");
2198  output_storage (" x[3] = px[2];");
2199  output_storage (" x[4] = px[1];");
2200  output_storage (" x[5] = px[0];");
2201  output_storage (" n >>= 16; /* Shift with sign */");
2202  output_storage (" n -= val;");
2203  output_storage (" x = (unsigned char *)&n;");
2204  output_storage (" px[0] = x[5];");
2205  output_storage (" px[1] = x[4];");
2206  output_storage (" px[2] = x[3];");
2207  output_storage (" px[3] = x[2];");
2208  output_storage (" px[4] = x[1];");
2209  output_storage (" px[5] = x[0];");
2210  output_storage ("}");
2211  return;
2212 
2213  case COB_SUBSWP_U56:
2214  output_storage ("static COB_INLINE COB_A_INLINE void");
2215  output_storage ("cob_subswp_u56 (void *p, const int val)");
2216  output_storage ("{");
2217  output_storage (" cob_u64_t n = 0;");
2218  output_storage (" unsigned char *x;");
2219  output_storage (" unsigned char *px = p;");
2220 
2221  output_storage (" x = (unsigned char *)&n;");
2222  output_storage (" x[0] = px[6];");
2223  output_storage (" x[1] = px[5];");
2224  output_storage (" x[2] = px[4];");
2225  output_storage (" x[3] = px[3];");
2226  output_storage (" x[4] = px[2];");
2227  output_storage (" x[5] = px[1];");
2228  output_storage (" x[6] = px[0];");
2229  output_storage (" n -= val;");
2230  output_storage (" px[0] = x[6];");
2231  output_storage (" px[1] = x[5];");
2232  output_storage (" px[2] = x[4];");
2233  output_storage (" px[3] = x[3];");
2234  output_storage (" px[4] = x[2];");
2235  output_storage (" px[5] = x[1];");
2236  output_storage (" px[6] = x[0];");
2237  output_storage ("}");
2238  return;
2239 
2240  case COB_SUBSWP_S56:
2241  output_storage ("static COB_INLINE COB_A_INLINE void");
2242  output_storage ("cob_subswp_s56 (void *p, const int val)");
2243  output_storage ("{");
2244  output_storage (" cob_s64_t n = 0;");
2245  output_storage (" unsigned char *x;");
2246  output_storage (" unsigned char *px = p;");
2247 
2248  output_storage (" x = ((unsigned char *)&n) + 1;");
2249  output_storage (" x[0] = px[6];");
2250  output_storage (" x[1] = px[5];");
2251  output_storage (" x[2] = px[4];");
2252  output_storage (" x[3] = px[3];");
2253  output_storage (" x[4] = px[2];");
2254  output_storage (" x[5] = px[1];");
2255  output_storage (" x[6] = px[0];");
2256  output_storage (" n >>= 8; /* Shift with sign */");
2257  output_storage (" n -= val;");
2258  output_storage (" x = (unsigned char *)&n;");
2259  output_storage (" px[0] = x[6];");
2260  output_storage (" px[1] = x[5];");
2261  output_storage (" px[2] = x[4];");
2262  output_storage (" px[3] = x[3];");
2263  output_storage (" px[4] = x[2];");
2264  output_storage (" px[5] = x[1];");
2265  output_storage (" px[6] = x[0];");
2266  output_storage ("}");
2267  return;
2268 
2269  case COB_SUBSWP_U64:
2270  output_storage ("static COB_INLINE COB_A_INLINE void");
2271  output_storage ("cob_subswp_u64 (void *p, const int val)");
2272  output_storage ("{");
2273  output_storage (" cob_u64_t n;");
2274 
2275 #ifdef COB_ALLOW_UNALIGNED
2276  output_storage (" n = COB_BSWAP_64 (*(cob_u64_t __unaligned *)p);");
2277  output_storage (" n -= val;");
2278  output_storage (" *(cob_u64_t __unaligned *)p = COB_BSWAP_64(n);");
2279 #else
2280  output_storage (" unsigned char *x;");
2281  output_storage (" unsigned char *px = p;");
2282 
2283  output_storage (" x = (unsigned char *)&n;");
2284  output_storage (" x[0] = px[7];");
2285  output_storage (" x[1] = px[6];");
2286  output_storage (" x[2] = px[5];");
2287  output_storage (" x[3] = px[4];");
2288  output_storage (" x[4] = px[3];");
2289  output_storage (" x[5] = px[2];");
2290  output_storage (" x[6] = px[1];");
2291  output_storage (" x[7] = px[0];");
2292  output_storage (" n -= val;");
2293  output_storage (" px[0] = x[7];");
2294  output_storage (" px[1] = x[6];");
2295  output_storage (" px[2] = x[5];");
2296  output_storage (" px[3] = x[4];");
2297  output_storage (" px[4] = x[3];");
2298  output_storage (" px[5] = x[2];");
2299  output_storage (" px[6] = x[1];");
2300  output_storage (" px[7] = x[0];");
2301 #endif
2302  output_storage ("}");
2303  return;
2304 
2305  case COB_SUBSWP_S64:
2306  output_storage ("static COB_INLINE COB_A_INLINE void");
2307  output_storage ("cob_subswp_s64 (void *p, const int val)");
2308  output_storage ("{");
2309  output_storage (" cob_s64_t n;");
2310 
2311 #ifdef COB_ALLOW_UNALIGNED
2312  output_storage (" n = COB_BSWAP_64 (*(cob_s64_t __unaligned *)p);");
2313  output_storage (" n -= val;");
2314  output_storage (" *(cob_s64_t __unaligned *)p = COB_BSWAP_64(n);");
2315 #else
2316  output_storage (" unsigned char *x;");
2317  output_storage (" unsigned char *px = p;");
2318 
2319  output_storage (" x = (unsigned char *)&n;");
2320  output_storage (" x[0] = px[7];");
2321  output_storage (" x[1] = px[6];");
2322  output_storage (" x[2] = px[5];");
2323  output_storage (" x[3] = px[4];");
2324  output_storage (" x[4] = px[3];");
2325  output_storage (" x[5] = px[2];");
2326  output_storage (" x[6] = px[1];");
2327  output_storage (" x[7] = px[0];");
2328  output_storage (" n -= val;");
2329  output_storage (" px[0] = x[7];");
2330  output_storage (" px[1] = x[6];");
2331  output_storage (" px[2] = x[5];");
2332  output_storage (" px[3] = x[4];");
2333  output_storage (" px[4] = x[3];");
2334  output_storage (" px[5] = x[2];");
2335  output_storage (" px[6] = x[1];");
2336  output_storage (" px[7] = x[0];");
2337 #endif
2338  output_storage ("}");
2339  return;
2340 
2341  /* Binary set swapped value */
2342  case COB_SETSWP_U16:
2343  output_storage ("static COB_INLINE COB_A_INLINE void");
2344  output_storage ("cob_setswp_u16 (void *p, const int val)");
2345  output_storage ("{");
2346  output_storage (" unsigned short n;");
2347 
2348 #ifdef COB_ALLOW_UNALIGNED
2349  output_storage (" n = val;");
2350  output_storage (" *(unsigned short __unaligned *)p = COB_BSWAP_16(n);");
2351 #else
2352  output_storage (" unsigned char *x;");
2353  output_storage (" unsigned char *px = p;");
2354 
2355  output_storage (" n = val;");
2356  output_storage (" x = (unsigned char *)&n;");
2357  output_storage (" px[0] = x[1];");
2358  output_storage (" px[1] = x[0];");
2359 #endif
2360  output_storage ("}");
2361  return;
2362 
2363  case COB_SETSWP_S16:
2364  output_storage ("static COB_INLINE COB_A_INLINE void");
2365  output_storage ("cob_setswp_s16 (void *p, const int val)");
2366  output_storage ("{");
2367  output_storage (" short n;");
2368 
2369 #ifdef COB_ALLOW_UNALIGNED
2370  output_storage (" n = val;");
2371  output_storage (" *(short __unaligned *)p = COB_BSWAP_16(n);");
2372 #else
2373  output_storage (" unsigned char *x;");
2374  output_storage (" unsigned char *px = p;");
2375 
2376  output_storage (" n = val;");
2377  output_storage (" x = (unsigned char *)&n;");
2378  output_storage (" px[0] = x[1];");
2379  output_storage (" px[1] = x[0];");
2380 #endif
2381  output_storage ("}");
2382  return;
2383 
2384  case COB_SETSWP_U24:
2385  output_storage ("static COB_INLINE COB_A_INLINE void");
2386  output_storage ("cob_setswp_u24 (void *p, const int val)");
2387  output_storage ("{");
2388  output_storage (" unsigned char *x;");
2389  output_storage (" unsigned char *px = p;");
2390  output_storage (" unsigned int n;");
2391 
2392  output_storage (" n = val;");
2393  output_storage (" x = (unsigned char *)&n;");
2394  output_storage (" px[0] = x[2];");
2395  output_storage (" px[1] = x[1];");
2396  output_storage (" px[2] = x[0];");
2397  output_storage ("}");
2398  return;
2399 
2400  case COB_SETSWP_S24:
2401  output_storage ("static COB_INLINE COB_A_INLINE void");
2402  output_storage ("cob_setswp_s24 (void *p, const int val)");
2403  output_storage ("{");
2404  output_storage (" unsigned char *x;");
2405  output_storage (" unsigned char *px = p;");
2406  output_storage (" int n;");
2407 
2408  output_storage (" n = val;");
2409  output_storage (" x = (unsigned char *)&n;");
2410  output_storage (" px[0] = x[2];");
2411  output_storage (" px[1] = x[1];");
2412  output_storage (" px[2] = x[0];");
2413  output_storage ("}");
2414  return;
2415 
2416  case COB_SETSWP_U32:
2417  output_storage ("static COB_INLINE COB_A_INLINE void");
2418  output_storage ("cob_setswp_u32 (void *p, const int val)");
2419  output_storage ("{");
2420  output_storage (" unsigned int n;");
2421 
2422 #ifdef COB_ALLOW_UNALIGNED
2423  output_storage (" n = val;");
2424  output_storage (" *(unsigned int __unaligned *)p = COB_BSWAP_32(n);");
2425 #else
2426  output_storage (" unsigned char *x;");
2427  output_storage (" unsigned char *px = p;");
2428 
2429  output_storage (" n = val;");
2430  output_storage (" x = (unsigned char *)&n;");
2431  output_storage (" px[0] = x[3];");
2432  output_storage (" px[1] = x[2];");
2433  output_storage (" px[2] = x[1];");
2434  output_storage (" px[3] = x[0];");
2435 #endif
2436  output_storage ("}");
2437  return;
2438 
2439  case COB_SETSWP_S32:
2440  output_storage ("static COB_INLINE COB_A_INLINE void");
2441  output_storage ("cob_setswp_s32 (void *p, const int val)");
2442  output_storage ("{");
2443  output_storage (" int n;");
2444 
2445 #ifdef COB_ALLOW_UNALIGNED
2446  output_storage (" n = val;");
2447  output_storage (" *(int __unaligned *)p = COB_BSWAP_32(n);");
2448 #else
2449  output_storage (" unsigned char *x;");
2450  output_storage (" unsigned char *px = p;");
2451 
2452  output_storage (" n = val;");
2453  output_storage (" x = (unsigned char *)&n;");
2454  output_storage (" px[0] = x[3];");
2455  output_storage (" px[1] = x[2];");
2456  output_storage (" px[2] = x[1];");
2457  output_storage (" px[3] = x[0];");
2458 #endif
2459  output_storage ("}");
2460  return;
2461 
2462  case COB_SETSWP_U40:
2463  output_storage ("static COB_INLINE COB_A_INLINE void");
2464  output_storage ("cob_setswp_u40 (void *p, const int val)");
2465  output_storage ("{");
2466  output_storage (" cob_u64_t n;");
2467  output_storage (" unsigned char *x;");
2468  output_storage (" unsigned char *px = p;");
2469 
2470  output_storage (" n = val;");
2471  output_storage (" x = (unsigned char *)&n;");
2472  output_storage (" px[0] = x[4];");
2473  output_storage (" px[1] = x[3];");
2474  output_storage (" px[2] = x[2];");
2475  output_storage (" px[3] = x[1];");
2476  output_storage (" px[4] = x[0];");
2477  output_storage ("}");
2478  return;
2479 
2480  case COB_SETSWP_S40:
2481  output_storage ("static COB_INLINE COB_A_INLINE void");
2482  output_storage ("cob_setswp_s40 (void *p, const int val)");
2483  output_storage ("{");
2484  output_storage (" cob_s64_t n;");
2485  output_storage (" unsigned char *x;");
2486  output_storage (" unsigned char *px = p;");
2487 
2488  output_storage (" n = val;");
2489  output_storage (" x = (unsigned char *)&n;");
2490  output_storage (" px[0] = x[4];");
2491  output_storage (" px[1] = x[3];");
2492  output_storage (" px[2] = x[2];");
2493  output_storage (" px[3] = x[1];");
2494  output_storage (" px[4] = x[0];");
2495  output_storage ("}");
2496  return;
2497 
2498  case COB_SETSWP_U48:
2499  output_storage ("static COB_INLINE COB_A_INLINE void");
2500  output_storage ("cob_setswp_u48 (void *p, const int val)");
2501  output_storage ("{");
2502  output_storage (" cob_u64_t n;");
2503  output_storage (" unsigned char *x;");
2504  output_storage (" unsigned char *px = p;");
2505 
2506  output_storage (" n = val;");
2507  output_storage (" x = (unsigned char *)&n;");
2508  output_storage (" px[0] = x[5];");
2509  output_storage (" px[1] = x[4];");
2510  output_storage (" px[2] = x[3];");
2511  output_storage (" px[3] = x[2];");
2512  output_storage (" px[4] = x[1];");
2513  output_storage (" px[5] = x[0];");
2514  output_storage ("}");
2515  return;
2516 
2517  case COB_SETSWP_S48:
2518  output_storage ("static COB_INLINE COB_A_INLINE void");
2519  output_storage ("cob_setswp_s48 (void *p, const int val)");
2520  output_storage ("{");
2521  output_storage (" cob_s64_t n;");
2522  output_storage (" unsigned char *x;");
2523  output_storage (" unsigned char *px = p;");
2524 
2525  output_storage (" n = val;");
2526  output_storage (" x = (unsigned char *)&n;");
2527  output_storage (" px[0] = x[5];");
2528  output_storage (" px[1] = x[4];");
2529  output_storage (" px[2] = x[3];");
2530  output_storage (" px[3] = x[2];");
2531  output_storage (" px[4] = x[1];");
2532  output_storage (" px[5] = x[0];");
2533  output_storage ("}");
2534  return;
2535 
2536  case COB_SETSWP_U56:
2537  output_storage ("static COB_INLINE COB_A_INLINE void");
2538  output_storage ("cob_setswp_u56 (void *p, const int val)");
2539  output_storage ("{");
2540  output_storage (" cob_u64_t n;");
2541  output_storage (" unsigned char *x;");
2542  output_storage (" unsigned char *px = p;");
2543 
2544  output_storage (" n = val;");
2545  output_storage (" x = (unsigned char *)&n;");
2546  output_storage (" px[0] = x[6];");
2547  output_storage (" px[1] = x[5];");
2548  output_storage (" px[2] = x[4];");
2549  output_storage (" px[3] = x[3];");
2550  output_storage (" px[4] = x[2];");
2551  output_storage (" px[5] = x[1];");
2552  output_storage (" px[6] = x[0];");
2553  output_storage ("}");
2554  return;
2555 
2556  case COB_SETSWP_S56:
2557  output_storage ("static COB_INLINE COB_A_INLINE void");
2558  output_storage ("cob_setswp_s56 (void *p, const int val)");
2559  output_storage ("{");
2560  output_storage (" cob_s64_t n;");
2561  output_storage (" unsigned char *x;");
2562  output_storage (" unsigned char *px = p;");
2563 
2564  output_storage (" n = val;");
2565  output_storage (" x = (unsigned char *)&n;");
2566  output_storage (" px[0] = x[6];");
2567  output_storage (" px[1] = x[5];");
2568  output_storage (" px[2] = x[4];");
2569  output_storage (" px[3] = x[3];");
2570  output_storage (" px[4] = x[2];");
2571  output_storage (" px[5] = x[1];");
2572  output_storage (" px[6] = x[0];");
2573  output_storage ("}");
2574  return;
2575 
2576  case COB_SETSWP_U64:
2577  output_storage ("static COB_INLINE COB_A_INLINE void");
2578  output_storage ("cob_setswp_u64 (void *p, const int val)");
2579  output_storage ("{");
2580  output_storage (" cob_u64_t n;");
2581 
2582 #ifdef COB_ALLOW_UNALIGNED
2583  output_storage (" n = val;");
2584  output_storage (" *(cob_u64_t __unaligned *)p = COB_BSWAP_64(n);");
2585 #else
2586  output_storage (" unsigned char *x;");
2587  output_storage (" unsigned char *px = p;");
2588 
2589  output_storage (" n = val;");
2590  output_storage (" x = (unsigned char *)&n;");
2591  output_storage (" px[0] = x[7];");
2592  output_storage (" px[1] = x[6];");
2593  output_storage (" px[2] = x[5];");
2594  output_storage (" px[3] = x[4];");
2595  output_storage (" px[4] = x[3];");
2596  output_storage (" px[5] = x[2];");
2597  output_storage (" px[6] = x[1];");
2598  output_storage (" px[7] = x[0];");
2599 #endif
2600  output_storage ("}");
2601  return;
2602 
2603  case COB_SETSWP_S64:
2604  output_storage ("static COB_INLINE COB_A_INLINE void");
2605  output_storage ("cob_setswp_s64 (void *p, const int val)");
2606  output_storage ("{");
2607  output_storage (" cob_s64_t n;");
2608 
2609 #ifdef COB_ALLOW_UNALIGNED
2610  output_storage (" n = val;");
2611  output_storage (" *(cob_s64_t __unaligned *)p = COB_BSWAP_64(n);");
2612 #else
2613  output_storage (" unsigned char *x;");
2614  output_storage (" unsigned char *px = p;");
2615 
2616  output_storage (" n = val;");
2617  output_storage (" x = (unsigned char *)&n;");
2618  output_storage (" px[0] = x[7];");
2619  output_storage (" px[1] = x[6];");
2620  output_storage (" px[2] = x[5];");
2621  output_storage (" px[3] = x[4];");
2622  output_storage (" px[4] = x[3];");
2623  output_storage (" px[5] = x[2];");
2624  output_storage (" px[6] = x[1];");
2625  output_storage (" px[7] = x[0];");
2626 #endif
2627  output_storage ("}");
2628  return;
2629  default:
2630  break;
2631  }
2632  cobc_abort_pr (_("Unexpected optimization value"));
2633  COBC_ABORT ();
2634 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
static void output_storage(const char *fmt,...)
Definition: codeoptim.c:35
#define _(s)
Definition: cobcrun.c:59
#define COBC_ABORT()
Definition: cobc.h:61

Here is the call graph for this function:

Here is the caller graph for this function:

static void output_storage ( const char *  fmt,
  ... 
)
static

Definition at line 35 of file codeoptim.c.

References cb_storage_file.

Referenced by cob_gen_optim().

36 {
37  va_list ap;
38 
39  if (cb_storage_file) {
40  va_start (ap, fmt);
41  vfprintf (cb_storage_file, fmt, ap);
42  va_end (ap);
43  fputc ('\n', cb_storage_file);
44  }
45 }
FILE * cb_storage_file
Definition: cobc.c:156

Here is the caller graph for this function: