I don't understand why everyone seems to cast to int * and not void *.

Chasing control blocks is simple in C just using a basic macro.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctest.h>

#define ptr(addr) (void *)((char *)addr)

char * userid(void)
{
  void ** ascb;      // -> ASCB     - address space control block
  void ** asxb;      // -> ASXB     - address space extension block
  char *  asxbuser;  // -> ASCBUSER - userid
  ascb     = ptr(548);         // -> ASCB
  asxb     = ptr(*ascb+108);   // ASCB+108 -> ASXB
  asxbuser = ptr(*asxb+192);   // ASXB+192 -> ASXBUSER
  return asxbuser;
}

main()
{
printf("'%8.8s'\n",userid());
  return 0;
}

Of course, we're all waiting on IBM to supply C header files for the assembler macros.

On 9/02/2018 3:47 AM, Bernd Oppolzer wrote:
int *ASCB;
int      *ASXB;
ASXB = ASCB + 0x6c;

because ASCB is a pointer to int, and int has sizeof = 4,
you are in fact adding 4 * 0x6c to ASCB, that's your problem.

use the following notation, and it will work:

ASXB = (int *) ((char *) ASCB + 0x6c);

first you cast the ASCB to a char *, then you REALLY add 0x6c,
and then you cast the result back to int *.

That's C ... the other solutions suggested (templates etc.) are C++
and don't apply in your case.

HTH, kind regards

Bernd



Am 08.02.2018 um 17:45 schrieb Barkow, Eileen:
Thank you Charles and Seymore. I thought that the problem had something to do with adding to pointers but
I could not find any doc about it in the manuals.
I am still not sure that I understand how to fix it but I will try based on your info.



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to