Exemple #1
0
void closelibrary()
{
  char libname[MAXIDSIZE],ut_libname[MAXIDSIZE];
  int  cc;
  /* close one or more shared libraries */ 

  insymbol();
  if (sym != ident && sym != stringconst) {
	/* 
	** Close all open shared libraries not 
	** normally closed by ACE at the end of
	** the program run.
	*/
	cc=0;
	while (otherlib[cc].name[0] != '\0' &&
		   strcmp(otherlib[cc].name,"SENTINEL") != 0)
	  {
    	gen_load32a(otherlib[cc].base,1);  /* library base in a1 */
    	gen_jsr("_close_library");
		gen_save32_val(0,otherlib[cc].base);
        enter_XREF("_close_library");
		cc++;
	  }  	
  } else {
	/* close a single shared library */
	get_libname(libname,ut_libname);  /* without extension! */
	
	if (check_for_ace_lib(libname) == NEGATIVE) {
	  make_library_base(libname);
	  gen_close_library(librarybase);
	}
	insymbol();
  }
}
Exemple #2
0
void library()
{
  char libname[MAXIDSIZE],ut_libname[MAXIDSIZE];

 /* open or close a shared library */

 insymbol();
 if (sym == closesym) closelibrary();
 else {
  if (sym != ident && sym != stringconst) 
	_error(7);  /* identifier expected */
  else {
	get_libname(libname,ut_libname);  /* without extension! */

	if (check_for_ace_lib(libname) == NEGATIVE) {
	  make_library_name(ut_libname); /* exec names are case sensitive */
	  make_string_const(libraryname);
	  gen_open_library(libname,librarybase);
	  /* enter new library info' into "other libraries" list */
	  enter_new_library(libname);
	}
  }
  insymbol();
 }
}       
SOL_API int
sol_util_get_rootdir(char *out, size_t size)
{
    char progname[PATH_MAX] = { 0 };
    const char *substr;
    int r;

    r = get_libname(progname, sizeof(progname));
    if (r < 0 || r >= (int)sizeof(progname)) {
        r = get_progname(progname, sizeof(progname));
        if (r < 0 || r >= (int)sizeof(progname))
            return r;
    }

    substr = strrstr(progname, PREFIX);
    if (!substr) {
        return -1;
    }

    r = snprintf(out, size, "%.*s/", (int)(strlen(progname) - strlen(substr)), progname);
    return (r < 0 || r >= (int)size) ? -ENOMEM : r;
}
Exemple #4
0
int main(int argc, char *argv[]){

#ifdef FORCE
  char buffer[8192], *p, *q;
  int length;
#endif

  if (argc == 1) return 0;

  switch (argv[1][0]) {

  case '0' : /* for Makefile */

#ifdef FORCE
    printf("CORE=%s\n", CORENAME);
#else
#if defined(INTEL_AMD) || defined(POWER) || defined(__mips__) || defined(__arm__) || defined(__aarch64__)
    printf("CORE=%s\n", get_corename());
#endif
#endif

#ifdef FORCE
    printf("LIBCORE=%s\n", LIBNAME);
#else
    printf("LIBCORE=");
    get_libname();
    printf("\n");
#endif

    printf("NUM_CORES=%d\n", get_num_cores());

#if defined(__arm__) && !defined(FORCE)
        get_features();
#endif


#ifdef INTEL_AMD
#ifndef FORCE
    get_sse();
#else

    sprintf(buffer, "%s", ARCHCONFIG);

    p = &buffer[0];

    while (*p) {
      if ((*p == '-') && (*(p + 1) == 'D')) {
	p += 2;

	while ((*p != ' ') && (*p != '\0')) {

	  if (*p == '=') {
	    printf("=");
	    p ++;
	    while ((*p != ' ') && (*p != '\0')) {
	      printf("%c", *p);
	      p ++;
	    }
	  } else {
	    printf("%c", *p);
	    p ++;
	    if ((*p == ' ') || (*p =='\0')) printf("=1");
	  }
	}

	printf("\n");
      } else p ++;
    }
#endif
#endif

#ifdef MAKE_NB_JOBS
    printf("MAKE += -j %d\n", MAKE_NB_JOBS);
#elif NO_PARALLEL_MAKE==1
    printf("MAKE += -j 1\n");
#else
#ifndef OS_WINDOWS
    printf("MAKE += -j %d\n", get_num_cores());
#endif
#endif

    break;

  case '1' : /* For config.h */
#ifdef FORCE
    sprintf(buffer, "%s -DCORE_%s\n", ARCHCONFIG, CORENAME);

    p = &buffer[0];
    while (*p) {
      if ((*p == '-') && (*(p + 1) == 'D')) {
	p += 2;
	printf("#define ");

	while ((*p != ' ') && (*p != '\0')) {

	  if (*p == '=') {
	    printf(" ");
	    p ++;
	    while ((*p != ' ') && (*p != '\0')) {
	      printf("%c", *p);
	      p ++;
	    }
	  } else {
	    printf("%c", *p);
	    p ++;
	  }
	}

	printf("\n");
      } else p ++;
    }
#else
    get_cpuconfig();
#endif

#ifdef FORCE
    printf("#define CHAR_CORENAME \"%s\"\n", CORENAME);
#else
#if defined(INTEL_AMD) || defined(POWER) || defined(__mips__) || defined(__arm__) || defined(__aarch64__)
    printf("#define CHAR_CORENAME \"%s\"\n", get_corename());
#endif
#endif

 break;

  case '2' : /* SMP */
    if (get_num_cores() > 1) printf("SMP=1\n");
    break;
  }

  fflush(stdout);

  return 0;
}
Exemple #5
0
void declare()
{
/* - declare a library function -- NOT optional. 
   - declare an external function -- NOT optional.
   - declare a forward reference to a SUB. 
   - declare an instance of a structure. 
*/

char funcname[MAXIDSIZE],ut_funcname[MAXIDSIZE];
char libname[MAXIDSIZE],ut_libname[MAXIDSIZE];
char extfuncname[MAXIDSIZE+1];
int  oldlevel,cc;
int  functype=undefined;
SYM  *declared_func;
BOOL found;

 /* all functions and structures must be declared at level ZERO */

 oldlevel=lev;
 lev=ZERO;

 insymbol();

 if (sym == subsym) { lev=oldlevel; forward_ref(); return; }

 if (sym == structsym) { lev=oldlevel; declare_structure(); return; }

 if (sym != functionsym) _error(47);
 else
 {
  insymbol();

  /* type identifiers */
  functype = sym_to_opt_type();

  if (sym != ident) _error(7);
  else {
   /* get the function's name */
   strcpy(funcname,id);
   strcpy(ut_funcname,ut_id);  /* case sensitive version for search! */
   remove_qualifier(funcname);
   remove_qualifier(ut_funcname);
   if (functype == undefined) functype = typ;

   /* get the LIBRARY symbol and/or parameter list */ 
   insymbol();

   /* parse parameter list? */
   if (sym == lparen)
   {    
    do
    {   
        insymbol();

	if (sym == rparen && lastsym == lparen) break;  /* FuncName() */

	/* type indentifier? */
        if (sym == shortintsym || sym == longintsym || sym == addresssym ||
      	    sym == singlesym || sym == stringsym) 
	insymbol();

	/* parameter */
	if (sym != ident) _error(7);
	else insymbol();
    } while (sym == comma);

    if (sym != rparen) _error(9);
    else insymbol();
   }
   
   /* EXTERNAL or LIBRARY function? */
   if (sym == externalsym) {
	 if (ut_funcname[0] != '_')
	{
	   	strcpy(extfuncname,"_\0");
		strcat(extfuncname,ut_funcname);
	}
	else
		strcpy(extfuncname,ut_funcname);

	enter(extfuncname,functype,extfunc,0);
	enter_XREF(extfuncname);	

	insymbol();
   }
   else
   if (sym != librarysym) _error(48);
   else
   {
    enter(funcname,functype,function,0); /* enter into symbol table */ 
    declared_func=curr_item;

    insymbol();

    if (sym != ident && sym != stringconst)
    {
	/* 
	** Search all bmap files found in acelib and otherlib arrays 
	** for function since no library was specified.
  	*/

	found=FALSE;

	/* acelib array */
	cc=0;
	while (!found && acelib[cc].name[0] != '\0' &&
	       strcmp(acelib[cc].name,"SENTINEL") != 0)
	{
	  found = found_func(acelib[cc].name,ut_funcname,declared_func);
	  cc++;
	}

	if (found) { lev=oldlevel; return; }

	/* otherlib array */
	cc=0;
	while (!found && otherlib[cc].name[0] != '\0' &&
	       strcmp(otherlib[cc].name,"SENTINEL") != 0)
	{
	  found = found_func(otherlib[cc].name,ut_funcname,declared_func);
	  cc++;
	}	

	if (!found) _error(49);
    }
    else
    {
     	/* 
	** Search specified library (bmap file) for the declared function.
	*/
     	get_libname(libname,ut_libname);  /* without extension! */

	if (!found_func(libname,ut_funcname,declared_func)) 
	  _error(49); 

        insymbol();
    }
   }  
  }    
 }
 lev=oldlevel;
}