Skip to content

Instantly share code, notes, and snippets.

@ztmr
Created July 29, 2012 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ztmr/3199510 to your computer and use it in GitHub Desktop.
Save ztmr/3199510 to your computer and use it in GitHub Desktop.
GT.M Call-ins and (un)signed int/longint values
test(x) q -$g(x)
/*
* $ setenv gtm_dist /usr/lib/fis-gtm/V55000x64
* $ gcc -c bug.c -I$gtm_dist ; gcc bug.o -o bug -L $gtm_dist -Wl,-rpath=$gtm_dist -lgtmshr ; env GTMCI=bug.ci ./bug
*/
#include <stdio.h>
#include "gtmxc_types.h"
#define BUFLEN 512
int check_status (gtm_status_t status, char msg []) {
if (status != 0) {
gtm_zstatus (msg, BUFLEN);
fprintf (stderr, "Error: %s\n", msg);
return -10;
}
return 0;
}
long test_int_v1 (long x) {
long res = 0;
char emsg [BUFLEN];
gtm_status_t status = gtm_ci ("m_test1", &res, x);
check_status (status, emsg);
return res;
}
long test_int_v2 (long x) {
long res = 0;
char emsg [BUFLEN];
char input [BUFLEN];
snprintf (input, BUFLEN-1, "%ld", x);
gtm_status_t status = gtm_ci ("m_test2", &res, &input);
check_status (status, emsg);
return res;
}
int main () {
char emsg [BUFLEN];
gtm_status_t status;
status = gtm_init ();
check_status (status, emsg);
long i, x;
for (i = 0, x = 5; x > -5; i++, x--)
printf ("%ld: -(%2ld) is: %2ld = %2ld\n", i, x,
test_int_v1 (x), test_int_v2 (x));
status = gtm_exit ();
check_status (status, emsg);
return 0;
}
m_test1 :gtm_long_t * test^%bug(I:gtm_long_t)
m_test2 :gtm_long_t * test^%bug(I:gtm_char_t *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment