Codebase list ibutils / debian/1.5.7+0.2.gbd7e502-3 ibmgtsim / src / inttypes.i
debian/1.5.7+0.2.gbd7e502-3

Tree @debian/1.5.7+0.2.gbd7e502-3 (Download .tar.gz)

inttypes.i @debian/1.5.7+0.2.gbd7e502-3raw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
/*
 * Copyright (c) 2004-2010 Mellanox Technologies LTD. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */

%typemap(tcl8,in) uint64_t *(uint64_t temp) {
  temp = strtoull(Tcl_GetStringFromObj($source,NULL), NULL,16);
  $target = &temp;
}

%typemap(tcl8,out) uint64_t *, uint64_t {
  char buff[20];
  sprintf(buff, "0x%016" PRIx64, *$source);
  Tcl_SetStringObj($target,buff,strlen(buff));
}

%typemap(tcl8,in) uint32_t * (uint32_t temp){
  temp = strtoul(Tcl_GetStringFromObj($source,NULL), NULL, 0);
  $target = &temp;
}

%typemap(tcl8,out) uint32_t * {
  char buff[20];
  sprintf(buff, "%u", *$source);
  Tcl_SetStringObj($target,buff,strlen(buff));
}

%typemap(tcl8,in) uint16_t * (uint16_t temp) {
  temp = strtoul(Tcl_GetStringFromObj($source,NULL), NULL, 0);
  $target = &temp;
}

%typemap(tcl8,out) uint16_t * {
  char buff[20];
  sprintf(buff, "%u", *$source);
  Tcl_SetStringObj($target,buff,strlen(buff));
}

%typemap(tcl8,in) uint8_t * (uint8_t temp) {
  temp = strtoul(Tcl_GetStringFromObj($source,NULL), NULL, 0);
  $target = &temp;
}

%typemap(tcl8,out) uint8_t * {
  char buff[20];
  sprintf(buff, "%u", *$source);
  Tcl_SetStringObj($target,buff,strlen(buff));
}

%typemap(tcl8,in) ib_net64_t *(uint64_t temp) {
  temp = cl_hton64(strtoull(Tcl_GetStringFromObj($source,NULL), NULL, 16));
  $target = &temp;
}

%typemap(tcl8,out) ib_net64_t * {
  char buff[20];
  sprintf(buff, "0x%016" PRIx64, cl_ntoh64(*$source));
  Tcl_SetStringObj($target,buff,strlen(buff));
}

%typemap(tcl8,in) ib_net32_t *(ib_net32_t temp) {
  temp = cl_hton32(strtoul(Tcl_GetStringFromObj($source,NULL), NULL, 0));
  $target = &temp;
}

%typemap(tcl8,out) ib_net32_t * {
  char buff[20];
  sprintf(buff, "%u", cl_ntoh32(*$source));
  Tcl_SetStringObj($target,buff,strlen(buff));
}

%typemap(tcl8,in) ib_net16_t * (ib_net16_t temp) {
  temp = cl_hton16(strtoul(Tcl_GetStringFromObj($source,NULL), NULL, 0));
  $target = &temp;
}

%typemap(tcl8,out) ib_net16_t * {
  char buff[20];
  sprintf(buff, "%u", cl_hton16(*$source));
  Tcl_SetStringObj($target,buff,strlen(buff));
}

%typemap(tcl8,argout) uint64_t *OUTPUT {
  char buff[20];
  sprintf(buff, "0x%016" PRIx64, *$source);
  Tcl_SetStringObj($target,buff,strlen(buff));
}

%typemap(tcl8,ignore) uint64_t *OUTPUT(uint64_t temp) {
  $target = &temp;
}

%typemap(tcl8,out) boolean_t * {
  if (*$source) {
	 Tcl_SetStringObj($target,"TRUE", 4);
  } else {
	 Tcl_SetStringObj($target,"FALSE", 5);
  }
}

%typemap(tcl8,in) boolean_t *(boolean_t temp) {
  if (strcmp(Tcl_GetStringFromObj($source,NULL), "TRUE")) {
	 temp = FALSE;
  } else {
	 temp = TRUE;
  }
  $target = &temp;
}

%typemap (tcl8, ignore) char **p_out_str (char *p_c) {
  $target = &p_c;
}

%typemap (tcl8, argout) char **p_out_str {
  Tcl_SetStringObj($target,*$source,strlen(*$source));
  if (*$source) free(*$source);
}

/* handle char arrays as members of a struct */
%typemap (tcl8, memberin) char [ANY] {
  strncpy($target,$source,$dim0 - 1);
  $target[$dim0] = '\0';
}

%typemap(tcl8,out) ib_gid_t* {
  char buff[36];
  sprintf(buff, "0x%016" PRIx64 ":0x%016" PRIx64,
          cl_ntoh64($source->unicast.prefix),
          cl_ntoh64($source->unicast.interface_id)
          );
  Tcl_SetStringObj($target,buff,strlen(buff));
}

/* ---------------- handling array of uint8_t ---------------------- */
%{
#define uint8_array_t uint8_t
%}
%typemap(memberin) uint8_array_t[ANY] {
	int i;
	for (i=0; i <$dim0 ; i++) {
		$target[i] = *($source+i);
	}
}

%typemap(in) uint8_array_t[ANY] (uint8_t entrys[$dim0]) {
  char *buff;
  char *p_ch;
  char *last;
  long int entry;

  int i = 0;
  buff = (char *)malloc((strlen(Tcl_GetStringFromObj($source,NULL))+1)*sizeof(char));
  strcpy(buff, Tcl_GetStringFromObj($source,NULL));
  p_ch = strtok_r(buff, " \t",&last);
  while (p_ch && (i < $dim0))
  {
    entry = strtol(p_ch, NULL, 0);
    if (entry > 0xff)
    {
      printf("Error: wrong format or out of range value for expected uint8_t entry: %s\n", p_ch);
      return TCL_ERROR;
    }
    entrys[i++] = entry;
    p_ch = strtok_r(NULL, " \t", &last);
  }
  for (; i < $dim0; i++) entrys[i] = 0;

  free(buff);
  $target = entrys;
}

%typemap(tcl8, out) uint8_array_t[ANY] {
  int i;
  char buff[8];
  for (i=0; i <$dim0 ; i++) {
    sprintf(buff, "0x%02x ", *($source+i));
    Tcl_AppendResult(interp, buff, NULL);
  }
}

/* ---------------- handling array of uint16_t ---------------------- */
%{
#define uint16_array_t uint16_t
%}
%typemap(memberin) uint16_array_t[ANY] {
	int i;
	for (i=0; i <$dim0 ; i++) {
		$target[i] = *($source+i);
	}
}

%typemap(in) uint16_array_t[ANY] (uint16_t entrys[$dim0]) {
  char *buff;
  char *p_ch;
  char *last;
  long int entry;

  int i = 0;
  buff = (char *)malloc((strlen(Tcl_GetStringFromObj($source,NULL))+1)*sizeof(char));
  strcpy(buff, Tcl_GetStringFromObj($source,NULL));
  p_ch = strtok_r(buff, " \t",&last);
  while (p_ch && (i < $dim0))
  {
    entry = strtol(p_ch, NULL, 0);
    if (entry > 0xffff)
    {
      printf("Error: wrong format or out of range value for expected uint16_t entry: %s\n", p_ch);
      return TCL_ERROR;
    }
    entrys[i++] = entry;
    p_ch = strtok_r(NULL, " \t", &last);
  }
  for (; i < $dim0; i++) entrys[i] = 0;

  free(buff);
  $target = entrys;
}

%typemap(tcl8, out) uint16_array_t[ANY] {
  int i;
  char buff[8];
  for (i=0; i <$dim0 ; i++) {
    sprintf(buff, "0x%04x ", *($source+i));
    Tcl_AppendResult(interp, buff, NULL);
  }
}

/* ---------------- handling array of uint32_t ---------------------- */
%{
#define uint32_array_t uint32_t
%}
%typemap(memberin) uint32_array_t[ANY] {
	int i;
	for (i=0; i <$dim0 ; i++) {
		$target[i] = *($source+i);
	}
}

%typemap(in) uint32_array_t[ANY] (uint32_t entrys[$dim0]) {
  char *buff;
  char *p_ch;
  char *last;
  long int entry;

  int i = 0;
  buff = (char *)malloc((strlen(Tcl_GetStringFromObj($source,NULL))+1)*sizeof(char));
  strcpy(buff, Tcl_GetStringFromObj($source,NULL));
  p_ch = strtok_r(buff, " \t",&last);
  while (p_ch && (i < $dim0))
  {
    entry = strtol(p_ch, NULL, 0);
    if (entry > (long int)0xffffffff)
    {
      printf("Error: wrong format or out of range value for expected uint32_t entry: %s\n", p_ch);
      return TCL_ERROR;
    }
    entrys[i++] = entry;
    p_ch = strtok_r(NULL, " \t", &last);
  }
  for (; i < $dim0; i++) entrys[i] = 0;

  free(buff);
  $target = entrys;
}

%typemap(tcl8, out) uint32_array_t[ANY] {
  int i;
  char buff[12];
  for (i=0; i <$dim0 ; i++) {
    sprintf(buff, "0x%08x ", *($source+i));
    Tcl_AppendResult(interp, buff, NULL);
  }
}

/* ---------------- handling array of uint64_t ---------------------- */
%{
#define uint64_array_t uint64_t
%}
%typemap(memberin) uint64_array_t[ANY] {
	int i;
	for (i=0; i <$dim0 ; i++) {
		$target[i] = *($source+i);
	}
}

%typemap(in) uint64_array_t[ANY] (uint64_t entrys[$dim0]) {
  char *buff;
  char *p_ch;
  char *last;
  uint64_t entry;

  int i = 0;
  buff = (char *)malloc((strlen(Tcl_GetStringFromObj($source,NULL))+1)*sizeof(char));
  strcpy(buff, Tcl_GetStringFromObj($source,NULL));
  p_ch = strtok_r(buff, " \t",&last);
  while (p_ch && (i < $dim0))
  {
    entry = strtol(p_ch, NULL, 0);
    if (entry > 0xffffffffffffffffULL )
    {
      printf("Error: wrong format or out of range value for expected uint64_t entry: %s\n", p_ch);
      return TCL_ERROR;
    }
    entrys[i++] = entry;
    p_ch = strtok_r(NULL, " \t", &last);
  }
  for (; i < $dim0; i++) entrys[i] = 0;

  free(buff);
  $target = entrys;
}

%typemap(tcl8, out) uint64_array_t[ANY] {
  int i;
  char buff[20];
  for (i=0; i <$dim0 ; i++) {
    sprintf(buff, "0x%016" PRIx64 " ", *($source+i));
    Tcl_AppendResult(interp, buff, NULL);
  }
}

/* ---------------- handling array of ib_net16_t ---------------------- */
%{
#define ib_net16_array_t ib_net16_t
%}

/* note - no need for cl_hton since the "in" typemap will do */
%typemap(memberin) ib_net16_array_t[ANY] {
	int i;
	for (i=0; i <$dim0 ; i++) {
     $target[i] = *($source+i);
	}
}

%typemap(in) ib_net16_array_t[ANY] (ib_net16_t entrys[$dim0]) {
  char *buff;
  char *p_ch;
  char *last;
  long int entry;

  int i = 0;
  buff = (char *)malloc((strlen(Tcl_GetStringFromObj($source,NULL))+1)*sizeof(char));
  strcpy(buff, Tcl_GetStringFromObj($source,NULL));
  p_ch = strtok_r(buff, " \t",&last);
  while (p_ch && (i < $dim0))
  {
    entry = strtol(p_ch, NULL, 0);
    if (entry > 65535)
    {
      printf("Error: wrong format or out of range value for expected ib_net16_t entry: %s\n", p_ch);
      return TCL_ERROR;
    }
    entrys[i++] = cl_hton16(entry);
    p_ch = strtok_r(NULL, " \t", &last);
  }
  for (; i < $dim0; i++) entrys[i] = 0;

  free(buff);
  $target = entrys;
}

%typemap(tcl8, out) ib_net16_array_t[ANY] {
  int i;
  char buff[8];
  for (i=0; i <$dim0 ; i++) {
    sprintf(buff, "0x%04x ", cl_ntoh16(*($source+i)));
    Tcl_AppendResult(interp, buff, NULL);
  }
}

/* ---------------- handling array of ib_net32_t ---------------------- */
%{
#define ib_net32_array_t ib_net32_t
%}

/* note - no need for cl_hton since the "in" typemap will do */
%typemap(memberin) ib_net32_array_t[ANY] {
	int i;
	for (i=0; i <$dim0 ; i++) {
     $target[i] = *($source+i);
	}
}

%typemap(in) ib_net32_array_t[ANY] (ib_net32_t entrys[$dim0]) {
  char *buff;
  char *p_ch;
  char *last;
  uint32_t entry;

  int i = 0;
  buff = (char *)malloc((strlen(Tcl_GetStringFromObj($source,NULL))+1)*sizeof(char));
  strcpy(buff, Tcl_GetStringFromObj($source,NULL));
  p_ch = strtok_r(buff, " \t",&last);
  while (p_ch && (i < $dim0))
  {
    entry = strtol(p_ch, NULL, 0);
    if (entry > 0xffffffff)
    {
      printf("Error: wrong format or out of range value for expected ib_net32_t entry: %s\n", p_ch);
      return TCL_ERROR;
    }
    entrys[i++] = cl_hton32(entry);
    p_ch = strtok_r(NULL, " \t", &last);
  }
  for (; i < $dim0; i++) entrys[i] = 0;

  free(buff);
  $target = entrys;
}

%typemap(tcl8, out) ib_net32_array_t[ANY] {
  int i;
  char buff[12];
  for (i=0; i <$dim0 ; i++) {
    sprintf(buff, "0x%08x ", cl_ntoh32(*($source+i)));
    Tcl_AppendResult(interp, buff, NULL);
  }
}

/* ---------------- handling array of ib_net64_t ---------------------- */
%{
#define ib_net64_array_t ib_net64_t
%}

/* note - no need for cl_hton since the "in" typemap will do */
%typemap(memberin) ib_net64_array_t[ANY] {
	int i;
	for (i=0; i <$dim0 ; i++) {
     $target[i] = *($source+i);
	}
}

%typemap(in) ib_net64_array_t[ANY] (ib_net64_t entrys[$dim0]) {
  char *buff;
  char *p_ch;
  char *last;
  uint64_t entry;

  int i = 0;
  buff = (char *)malloc((strlen(Tcl_GetStringFromObj($source,NULL))+1)*sizeof(char));
  strcpy(buff, Tcl_GetStringFromObj($source,NULL));
  p_ch = strtok_r(buff, " \t",&last);
  while (p_ch && (i < $dim0))
  {
    entry = strtoll(p_ch, NULL, 0);
    if (entry > 0xffffffffffffffffULL )
    {
      printf("Error: wrong format or out of range value for expected ib_net64_t entry: %s\n", p_ch);
      return TCL_ERROR;
    }
    entrys[i++] = cl_hton64(entry);
    p_ch = strtok_r(NULL, " \t", &last);
  }
  for (; i < $dim0; i++) entrys[i] = 0;

  free(buff);
  $target = entrys;
}

%typemap(tcl8, out) ib_net64_array_t[ANY] {
  int i;
  char buff[20];
  for (i=0; i <$dim0 ; i++) {
    sprintf(buff, "0x%016" PRIx64 " ", cl_ntoh64(*($source+i)));
    Tcl_AppendResult(interp, buff, NULL);
  }
}