Example #1
0
/**
 * Return pointer to the named function.  If the function name isn't found
 * in the name of static functions, try generating a new API entrypoint on
 * the fly with assembly language.
 */
_glapi_proc
_glapi_get_proc_address(const char *funcName)
{
   _glapi_proc func;
   struct _glapi_function * entry;

   init_glapi_relocs_once();

#ifdef MANGLE
   /* skip the prefix on the name */
   if (funcName[1] != 'g' || funcName[2] != 'l')
      return NULL;
#else
   if (funcName[0] != 'g' || funcName[1] != 'l')
      return NULL;
#endif

   /* search extension functions first */
   func = get_extension_proc_address(funcName);
   if (func)
      return func;

   /* search static functions */
   func = get_static_proc_address(funcName);
   if (func)
      return func;

   /* generate entrypoint, dispatch offset must be filled in by the driver */
   entry = add_function_name(funcName);
   if (entry == NULL)
      return NULL;

   return entry->dispatch_stub;
}
Example #2
0
/**
 * Return pointer to the named function.  If the function name isn't found
 * in the name of static functions, try generating a new API entrypoint on
 * the fly with assembly language.
 */
_glapi_proc
_glapi_get_proc_address(const char *funcName)
{
   _glapi_proc func;
   struct _glapi_function * entry;

   init_glapi_relocs_once();

#ifdef USE_MGL_NAMESPACE
   if (funcName && funcName[0] == 'm')
      funcName++;
#endif

  if (!funcName || funcName[0] != 'g' || funcName[1] != 'l')
      return NULL;

   /* search extension functions first */
   func = get_extension_proc_address(funcName);
   if (func)
      return func;

   /* search static functions */
   func = get_static_proc_address(funcName);
   if (func)
      return func;

   /* generate entrypoint, dispatch offset must be filled in by the driver */
   entry = add_function_name(funcName);
   if (entry == NULL)
      return NULL;

   return entry->dispatch_stub;
}
Example #3
0
int
_glapi_add_dispatch( const char * const * function_names,
		     const char * parameter_signature )
{
   static int next_dynamic_offset = FIRST_DYNAMIC_OFFSET;
   const char * const real_sig = (parameter_signature != NULL)
     ? parameter_signature : "";
   struct _glapi_function * entry[8];
   GLboolean is_static[8];
   unsigned i;
   int offset = ~0;

   init_glapi_relocs_once();

   (void) memset( is_static, 0, sizeof( is_static ) );
   (void) memset( entry, 0, sizeof( entry ) );

   /* Find the _single_ dispatch offset for all function names that already
    * exist (and have a dispatch offset).
    */

   for ( i = 0 ; function_names[i] != NULL ; i++ ) {
      const char * funcName = function_names[i];
      int static_offset;
      int extension_offset;

      if (funcName[0] != 'g' || funcName[1] != 'l')
         return -1;

      /* search built-in functions */
      static_offset = get_static_proc_offset(funcName);

      if (static_offset >= 0) {

	 is_static[i] = GL_TRUE;

	 /* FIXME: Make sure the parameter signatures match!  How do we get
	  * FIXME: the parameter signature for static functions?
	  */

	 if ( (offset != ~0) && (static_offset != offset) ) {
	    return -1;
	 }

	 offset = static_offset;

	 continue;
      }

      /* search added extension functions */
      entry[i] = get_extension_proc(funcName);

      if (entry[i] != NULL) {
	 extension_offset = entry[i]->dispatch_offset;

	 /* The offset may be ~0 if the function name was added by
	  * glXGetProcAddress but never filled in by the driver.
	  */

	 if (extension_offset == ~0) {
	    continue;
	 }

	 if (strcmp(real_sig, entry[i]->parameter_signature) != 0) {
	    return -1;
	 }

	 if ( (offset != ~0) && (extension_offset != offset) ) {
	    return -1;
	 }

	 offset = extension_offset;
      }
   }

   /* If all function names are either new (or with no dispatch offset),
    * allocate a new dispatch offset.
    */

   if (offset == ~0) {
      offset = next_dynamic_offset;
      next_dynamic_offset++;
   }

   /* Fill in the dispatch offset for the new function names (and those with
    * no dispatch offset).
    */

   for ( i = 0 ; function_names[i] != NULL ; i++ ) {
      if (is_static[i]) {
	 continue;
      }

      /* generate entrypoints for new function names */
      if (entry[i] == NULL) {
	 entry[i] = add_function_name( function_names[i] );
	 if (entry[i] == NULL) {
	    /* FIXME: Possible memory leak here. */
	    return -1;
	 }
      }

      if (entry[i]->dispatch_offset == ~0) {
	 set_entry_info( entry[i], real_sig, offset );
      }
   }

   return offset;
}