GnuCOBOL  2.0
A free COBOL compiler
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
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:

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)

References _, COBC_ABORT, cobc_abort_pr(), and output_storage().

Referenced by codegen().

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

References cb_storage_file.

Referenced by cob_gen_optim().

35 {
36  va_list ap;
37 
38  if (cb_storage_file) {
39  va_start (ap, fmt);
40  vfprintf (cb_storage_file, fmt, ap);
41  va_end (ap);
42  fputc ('\n', cb_storage_file);
43  }
44 }