Exemplo n.º 1
0
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/

#include <sys/types.h>
#include <string.h>


void *
memset(void *s, int c, size_t count)
{
    char *xs = (char *) s;

    while (count--)
        *xs++ = c;

    return s;
}

#ifdef __ARM__
void* __aeabi_memset(void *s, int c, size_t count)
__attribute__((__alias__("memset")));
#endif
Exemplo n.º 2
0
#endif
/**********************************************************************/
#ifdef L_mbsinit

int mbsinit(const mbstate_t *ps)
{
	return !ps || !ps->__mask;
}

#endif
/**********************************************************************/
#ifdef L_mbrlen

size_t mbrlen(const char *__restrict s, size_t n, mbstate_t *__restrict ps)
	 __attribute__ ((__weak__, __alias__("__mbrlen")));

size_t __mbrlen(const char *__restrict s, size_t n, mbstate_t *__restrict ps)
{
	static mbstate_t mbstate;	/* Rely on bss 0-init. */

	return mbrtowc(NULL, s, n, (ps != NULL) ? ps : &mbstate);
}

#endif
/**********************************************************************/
#ifdef L_mbrtowc

size_t mbrtowc(wchar_t *__restrict pwc, const char *__restrict s,
			   size_t n, mbstate_t *__restrict ps)
{
Exemplo n.º 3
0
#include "syscalls.h"
#define _LINUX_SOURCE
#include <fcntl.h>
#include <unistd.h>

#ifndef __NR_fadvise64
long fadvise64_64(int fd, off64_t offset, off64_t len, int advice)
{
  extern long __arm_fadvise64_64(int fd, int advice, off64_t offset, off64_t len);

  return __arm_fadvise64_64(fd, advice, offset, len);
}

int posix_fadvise(int fd, off64_t offset, off64_t len, int advise)
  __attribute__((__alias__("fadvise64_64")));
#endif
Exemplo n.º 4
0
void foo()
{
  extern void bar () __attribute__ ((__alias__ ("BAR")));
  bar ();
}
Exemplo n.º 5
0
     * 2) ELSE IF the dividend is an INFINITY OR the divisor is 0 THEN a INFINITY results.
     * 3) ELSE IF the dividend is 0 OR the divisor is INFINITY THEN a 0 results.
     */
    mult = spu_andc(mult, (vec_double2)spu_or(a_zero, b_inf));
    mult = spu_sel(mult, (vec_double2)exp_mask, spu_or(a_inf, b_zero));

    nan = spu_or(a_nan, b_nan);
    nan = spu_or(nan, spu_and(a_zero, b_zero));
    nan = spu_or(nan, spu_and(a_inf, b_inf));

    mult = spu_or(mult, (vec_double2)nan);

    /* Scale the final quotient */

    q2 = spu_mul(q1, mult);

    return (q2);
}


/* We use the same function for vector and scalar division.  Provide the
   scalar entry point as an alias.  */
double __divdf3 (double a, double b)
__attribute__ ((__alias__ ("__divv2df3")));

/* Some toolchain builds used the __fast_divdf3 name for this helper function.
   Provide this as another alternate entry point for compatibility.  */
double __fast_divdf3 (double a, double b)
__attribute__ ((__alias__ ("__divv2df3")));

Exemplo n.º 6
0
 * What follows is some macro magic to populate the
 * ISR vector table and to declare weak symbols for the handlers.
 *
 * We start by defining the macros VH and V, which by themselves
 * just call the (yet undefined) macro V_handler().
 *
 * V_handler will then be defined separately for each use of the
 * vector list.
 *
 * V_reserved is just used to properly skip the reserved entries
 * in the vector table.
 */

typedef void (isr_handler_t)(void);

isr_handler_t Default_Handler __attribute__((__weak__, __alias__("__Default_Handler")));
isr_handler_t Default_Reset_Handler;


#define VH(num, handler, default)                               \
	V_handler(num, handler, _CONCAT(handler, _Handler), default)
#define V(num, x)                               \
	VH(num, x, Default_Handler)

/**
 * Declare the weak symbols.  By default they will be aliased
 * to Default_Handler, but the default handler can be specified
 * by using VH() instead of V().
 */

#define V_handler(num, name, handler, default)                          \
Exemplo n.º 7
0
  case '>': s="&gt;"; goto string;
  case '\'': s="&apos;"; goto string;
  case '"': s="&quot;"; goto string;
  default:
    a[i=fmt_ulong(a,ch)]=0;
    b[0]='x';
    b[j=fmt_xlong(b+1,ch)+1]=0;
    s=a;
    if (i>j) { s=b; i=j; }
    if (dest) {
      dest[0]='&';
      dest[1]='#';
      byte_copy(dest+2,i,s);
      dest[i+2]=';';
    }
    return i+3;
  }
string:
  return fmt_str(dest,s);
}

#ifdef __GNUC__
#ifdef __APPLE__
size_t fmt_escapecharhtml(char* dest,uint32_t ch) {
  return fmt_escapecharxml(dest,ch);
}
#else
size_t fmt_escapecharhtml(char* dest,uint32_t ch) __attribute__((__alias__("fmt_escapecharxml")));
#endif
#endif
Exemplo n.º 8
0
/* { dg-require-alias "" } */
/* { dg-require-weak "" } */

static int dummy = 0;
extern int foo __attribute__((__weak__, __alias__("dummy")));
typedef char check[2*!__builtin_constant_p(dummy)-1];
typedef char check[2*!__builtin_constant_p(foo)-1];
Exemplo n.º 9
0
#include "rtld.h"

extern int main(int, char **, char **);

extern void	_init(void);
extern void	_fini(void);

/*
 * Arrange for _DYNAMIC to be weak and undefined (and therefore to show up
 * as being at address zero, unless something else defines it).  That way,
 * if we happen to be compiling without -static but with without any
 * shared libs present, things will still work.
 */

#if __GNUC_PREREQ__(4,2)
static int rtld_DYNAMIC __attribute__((__weakref__, __alias__("_DYNAMIC")));
#define	DYNAMIC_SYM	rtld_DYNAMIC
#else
extern int _DYNAMIC __weak_reference(_DYNAMIC);
#define	DYNAMIC_SYM	_DYNAMIC
#endif

#ifdef MCRT0
extern void	monstartup(u_long, u_long);
extern void	_mcleanup(void);
extern unsigned char __etext, __eprol;
#endif /* MCRT0 */

char		**environ;
struct ps_strings *__ps_strings = 0;
Exemplo n.º 10
0
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

int func(int x)
{
	return x;
}

__typeof__(func) func2
{
	return 0;
}

__typeof__(func) func3;

__typeof__(func) func4 __attribute__((weak, alias("func2")));
__typeof__(func) func5 __attribute__((__alias__("func2")));

__typeof__(func) func6 __attribute__((pinvoke("module.so"), ansi));
Exemplo n.º 11
0
		[DISPATCH_QUEUE_ATTR_CONCURRENCY_COUNT] = {
	DISPATCH_QUEUE_ATTR_QOS_INITIALIZER(UNSPECIFIED),
	DISPATCH_QUEUE_ATTR_QOS_INITIALIZER(MAINTENANCE),
	DISPATCH_QUEUE_ATTR_QOS_INITIALIZER(BACKGROUND),
	DISPATCH_QUEUE_ATTR_QOS_INITIALIZER(UTILITY),
	DISPATCH_QUEUE_ATTR_QOS_INITIALIZER(DEFAULT),
	DISPATCH_QUEUE_ATTR_QOS_INITIALIZER(USER_INITIATED),
	DISPATCH_QUEUE_ATTR_QOS_INITIALIZER(USER_INTERACTIVE),
};

// _dispatch_queue_attr_concurrent is aliased using libdispatch.aliases
// and the -alias_list linker option on Darwin but needs to be done manually
// for other platforms.
#ifndef __APPLE__
extern struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent
	__attribute__((__alias__("_dispatch_queue_attrs")));
#endif

#pragma mark -
#pragma mark dispatch_vtables

DISPATCH_VTABLE_INSTANCE(semaphore,
	.do_type = DISPATCH_SEMAPHORE_TYPE,
	.do_kind = "semaphore",
	.do_dispose = _dispatch_semaphore_dispose,
	.do_debug = _dispatch_semaphore_debug,
);

DISPATCH_VTABLE_INSTANCE(group,
	.do_type = DISPATCH_GROUP_TYPE,
	.do_kind = "group",
Exemplo n.º 12
0
#include <stdlib.h>
#include <features.h>
#include "dlfcn.h"
#include "linuxelf.h"
#include "ld_syscall.h"
#include "ld_hash.h"
#include "ld_string.h"

extern struct r_debug *_dl_debug_addr;

extern void *(*_dl_malloc_function) (size_t size);

static int do_fixup(struct elf_resolve *tpnt, int flag);
static int do_dlclose(void *, int need_fini);

void *dlopen(const char *, int) __attribute__ ((__weak__, __alias__ ("_dlopen")));
const char *dlerror(void) __attribute__ ((__weak__, __alias__ ("_dlerror")));
void *dlsym(void *, const char *) __attribute__ ((__weak__, __alias__ ("_dlsym")));
int dlclose(void *) __attribute__ ((__weak__, __alias__ ("_dlclose")));
int dladdr(void *, Dl_info *) __attribute__ ((__weak__, __alias__ ("_dladdr")));

#ifdef __PIC__
/* This is a real hack.  We need access to the dynamic linker, but we
also need to make it possible to link against this library without any
unresolved externals.  We provide these weak symbols to make the link
possible, but at run time the normal symbols are accessed. */
static void __attribute__ ((unused)) foobar(void)
{
	const char msg[]="libdl library not correctly linked\n";
	_dl_write(2, msg, _dl_strlen(msg));
	_dl_exit(1);
Exemplo n.º 13
0
#else
  va_start (ap);
#endif
  ret = _svfprintf_r (ptr, &f, fmt, ap);
  va_end (ap);
  if (ret < EOF)
    ptr->_errno = EOVERFLOW;
  if (size > 0)
    *f._p = 0;
  return (ret);
}

#ifdef _NANO_FORMATTED_IO
int
_EXFUN(_sniprintf_r, (struct _reent *, char *, size_t, const char *, ...)
       _ATTRIBUTE ((__alias__("_snprintf_r"))));
#endif

#ifndef _REENT_ONLY

int
#ifdef _HAVE_STDC
_DEFUN(snprintf, (str, size, fmt),
       char *__restrict str _AND
       size_t size _AND
       _CONST char *__restrict fmt _DOTS)
#else
snprintf(str, size, fmt, va_alist)
         char *str;
         size_t size;
         _CONST char *fmt;