3 @@ -313,6 +313,12 @@ ifeq ($(TARGET_ARCH),frv)
7 +ifeq ($(strip $(TARGET_ARCH)),avr32)
8 + CPU_CFLAGS-$(CONFIG_AVR32_AP7) += -march=ap
9 + CPU_CFLAGS-$(CONFIG_LINKRELAX) += -mrelax
10 + CPU_LDFLAGS-$(CONFIG_LINKRELAX) += --relax
13 # Keep the check_gcc from being needlessly executed
15 ifneq ($(UCLIBC_BUILD_PIE),y)
17 +++ b/extra/Configs/Config.avr32
20 +# For a description of the syntax of this configuration file,
21 +# see extra/config/Kconfig-language.txt
28 +config FORCE_OPTIONS_FOR_ARCH
31 + select ARCH_BIG_ENDIAN
32 + select FORCE_SHAREABLE_TEXT_SEGMENTS
38 + prompt "Target CPU Type"
39 + default CONFIG_AVR32_AP7
41 +config CONFIG_AVR32_AP7
48 + bool "Enable linker optimizations"
50 --- a/extra/Configs/Config.in
51 +++ b/extra/Configs/Config.in
52 @@ -16,6 +16,9 @@ config TARGET_alpha
62 @@ -92,6 +95,10 @@ if TARGET_arm
63 source "extra/Configs/Config.arm"
67 +source "extra/Configs/Config.avr32"
71 source "extra/Configs/Config.bfin"
74 +++ b/extra/Configs/defconfigs/avr32
79 @@ -354,6 +354,8 @@ typedef struct
80 /* NIOS magic number - no EABI available. */
81 #define EM_NIOS32 0xFEBB
83 +#define EM_AVR32 0x18ad
85 /* V850 backend magic number. Written in the absense of an ABI. */
86 #define EM_CYGNUS_V850 0x9080
88 @@ -2828,6 +2830,55 @@ typedef Elf32_Addr Elf32_Conflict;
89 /* Keep this the last entry. */
92 +/* Atmel AVR32 relocations. */
93 +#define R_AVR32_NONE 0
97 +#define R_AVR32_32_PCREL 4
98 +#define R_AVR32_16_PCREL 5
99 +#define R_AVR32_8_PCREL 6
100 +#define R_AVR32_DIFF32 7
101 +#define R_AVR32_DIFF16 8
102 +#define R_AVR32_DIFF8 9
103 +#define R_AVR32_GOT32 10
104 +#define R_AVR32_GOT16 11
105 +#define R_AVR32_GOT8 12
106 +#define R_AVR32_21S 13
107 +#define R_AVR32_16U 14
108 +#define R_AVR32_16S 15
109 +#define R_AVR32_8S 16
110 +#define R_AVR32_8S_EXT 17
111 +#define R_AVR32_22H_PCREL 18
112 +#define R_AVR32_18W_PCREL 19
113 +#define R_AVR32_16B_PCREL 20
114 +#define R_AVR32_16N_PCREL 21
115 +#define R_AVR32_14UW_PCREL 22
116 +#define R_AVR32_11H_PCREL 23
117 +#define R_AVR32_10UW_PCREL 24
118 +#define R_AVR32_9H_PCREL 25
119 +#define R_AVR32_9UW_PCREL 26
120 +#define R_AVR32_HI16 27
121 +#define R_AVR32_LO16 28
122 +#define R_AVR32_GOTPC 29
123 +#define R_AVR32_GOTCALL 30
124 +#define R_AVR32_LDA_GOT 31
125 +#define R_AVR32_GOT21S 32
126 +#define R_AVR32_GOT18SW 33
127 +#define R_AVR32_GOT16S 34
128 +#define R_AVR32_GOT7UW 35
129 +#define R_AVR32_32_CPENT 36
130 +#define R_AVR32_CPCALL 37
131 +#define R_AVR32_16_CP 38
132 +#define R_AVR32_9W_CP 39
133 +#define R_AVR32_RELATIVE 40
134 +#define R_AVR32_GLOB_DAT 41
135 +#define R_AVR32_JMP_SLOT 42
136 +#define R_AVR32_ALIGN 43
137 +#define R_AVR32_NUM 44
139 +/* AVR32 dynamic tags */
140 +#define DT_AVR32_GOTSZ 0x70000001 /* Total size of GOT in bytes */
142 /* Renesas H8/300 Relocations */
144 --- a/ldso/include/dl-string.h
145 +++ b/ldso/include/dl-string.h
146 @@ -285,7 +285,8 @@ static __always_inline char * _dl_simple
147 /* On some arches constant strings are referenced through the GOT.
148 * This requires that load_addr must already be defined... */
149 #if defined(mc68000) || defined(__arm__) || defined(__thumb__) || \
150 - defined(__mips__) || defined(__sh__) || defined(__powerpc__)
151 + defined(__mips__) || defined(__sh__) || defined(__powerpc__) || \
153 # define CONSTANT_STRING_GOT_FIXUP(X) \
154 if ((X) < (const char *) load_addr) (X) += load_addr
155 # define NO_EARLY_SEND_STDERR
156 --- a/ldso/include/dl-syscall.h
157 +++ b/ldso/include/dl-syscall.h
159 dynamic linking at all, so we cannot return any error codes.
160 We just punt if there is an error. */
161 #define __NR__dl_exit __NR_exit
162 -static inline _syscall1(void, _dl_exit, int, status);
163 +static __always_inline _syscall1(void, _dl_exit, int, status);
165 #define __NR__dl_close __NR_close
166 -static inline _syscall1(int, _dl_close, int, fd);
167 +static __always_inline _syscall1(int, _dl_close, int, fd);
169 #define __NR__dl_open __NR_open
170 -static inline _syscall3(int, _dl_open, const char *, fn, int, flags,
171 +static __always_inline _syscall3(int, _dl_open, const char *, fn, int, flags,
172 __kernel_mode_t, mode);
174 #define __NR__dl_write __NR_write
175 -static inline _syscall3(unsigned long, _dl_write, int, fd,
176 +static __always_inline _syscall3(unsigned long, _dl_write, int, fd,
177 const void *, buf, unsigned long, count);
179 #define __NR__dl_read __NR_read
180 -static inline _syscall3(unsigned long, _dl_read, int, fd,
181 +static __always_inline _syscall3(unsigned long, _dl_read, int, fd,
182 const void *, buf, unsigned long, count);
184 #define __NR__dl_mprotect __NR_mprotect
185 -static inline _syscall3(int, _dl_mprotect, const void *, addr,
186 +static __always_inline _syscall3(int, _dl_mprotect, const void *, addr,
187 unsigned long, len, int, prot);
189 #define __NR__dl_stat __NR_stat
190 -static inline _syscall2(int, _dl_stat, const char *, file_name,
191 +static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
194 #define __NR__dl_fstat __NR_fstat
195 -static inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
196 +static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
198 #define __NR__dl_munmap __NR_munmap
199 -static inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
200 +static __always_inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
203 # define __NR_getuid __NR_getxuid
205 #define __NR__dl_getuid __NR_getuid
206 -static inline _syscall0(uid_t, _dl_getuid);
207 +static __always_inline _syscall0(uid_t, _dl_getuid);
210 # define __NR_geteuid __NR_getuid
212 #define __NR__dl_geteuid __NR_geteuid
213 -static inline _syscall0(uid_t, _dl_geteuid);
214 +static __always_inline _syscall0(uid_t, _dl_geteuid);
217 # define __NR_getgid __NR_getxgid
219 #define __NR__dl_getgid __NR_getgid
220 -static inline _syscall0(gid_t, _dl_getgid);
221 +static __always_inline _syscall0(gid_t, _dl_getgid);
224 # define __NR_getegid __NR_getgid
226 #define __NR__dl_getegid __NR_getegid
227 -static inline _syscall0(gid_t, _dl_getegid);
228 +static __always_inline _syscall0(gid_t, _dl_getegid);
231 # define __NR_getpid __NR_getxpid
233 #define __NR__dl_getpid __NR_getpid
234 -static inline _syscall0(gid_t, _dl_getpid);
235 +static __always_inline _syscall0(gid_t, _dl_getpid);
237 #define __NR__dl_readlink __NR_readlink
238 -static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
239 +static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
242 #ifdef __UCLIBC_HAS_SSP__
243 @@ -146,14 +146,14 @@ static inline _syscall2(int, _dl_gettime
244 #if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
246 # define __NR__dl_mmap __NR_mmap
247 -static inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
248 +static __always_inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
249 int, prot, int, flags, int, fd, off_t, offset);
251 /* then try mmap2() */
252 #elif defined(__NR_mmap2)
254 # define __NR___syscall_mmap2 __NR_mmap2
255 -static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
256 +static __always_inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
257 int, prot, int, flags, int, fd, off_t, offset);
259 /* Some architectures always use 12 as page shift for mmap2() eventhough the
260 @@ -164,7 +164,7 @@ static inline _syscall6(__ptr_t, __sysca
261 # define MMAP2_PAGE_SHIFT 12
264 -static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
265 +static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
266 int flags, int fd, unsigned long offset)
268 if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
269 @@ -177,8 +177,8 @@ static inline void * _dl_mmap(void * add
270 #elif defined(__NR_mmap)
272 # define __NR__dl_mmap_real __NR_mmap
273 -static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
274 -static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
275 +static __always_inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
276 +static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
277 int flags, int fd, unsigned long offset)
279 unsigned long buffer[6];
281 +++ b/ldso/ldso/avr32/dl-debug.h
284 + * AVR32 ELF shared libary loader support
286 + * Copyright (C) 2005-2007 Atmel Corporation
287 + * All rights reserved.
289 + * Redistribution and use in source and binary forms, with or without
290 + * modification, are permitted provided that the following conditions
292 + * 1. Redistributions of source code must retain the above copyright
293 + * notice, this list of conditions and the following disclaimer.
294 + * 2. The name of the above contributors may not be
295 + * used to endorse or promote products derived from this software
296 + * without specific prior written permission.
298 + * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
299 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
300 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
301 + * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
302 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
303 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
304 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
305 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
306 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
307 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311 +static const char *_dl_reltypes_tab[] = {
313 + "R_AVR32_32", "R_AVR32_16", "R_AVR32_8",
314 + "R_AVR32_32_PCREL", "R_AVR32_16_PCREL", "R_AVR32_8_PCREL",
315 + "R_AVR32_DIFF32", "R_AVR32_DIFF16", "R_AVR32_DIFF8",
316 + "R_AVR32_GOT32", "R_AVR32_GOT16", "R_AVR32_GOT8",
317 + "R_AVR32_21S", "R_AVR32_16U", "R_AVR32_16S", "R_AVR32_8S", "R_AVR32_8S_EXT",
318 + "R_AVR32_22H_PCREL", "R_AVR32_18W_PCREL", "R_AVR32_16B_PCREL",
319 + "R_AVR32_16N_PCREL", "R_AVR32_14UW_PCREL", "R_AVR32_11H_PCREL",
320 + "R_AVR32_10UW_PCREL", "R_AVR32_9H_PCREL", "R_AVR32_9UW_PCREL",
321 + "R_AVR32_HI16", "R_AVR32_LO16",
322 + "R_AVR32_GOTPC", "R_AVR32_GOTCALL", "R_AVR32_LDA_GOT",
323 + "R_AVR32_GOT21S", "R_AVR32_GOT18SW", "R_AVR32_GOT16S", "R_AVR32_GOT7UW",
324 + "R_AVR32_32_CPENT", "R_AVR32_CPCALL", "R_AVR32_16_CP", "R_AVR32_9W_CP",
325 + "R_AVR32_RELATIVE", "R_AVR32_GLOB_DAT", "R_AVR32_JMP_SLOT",
329 +++ b/ldso/ldso/avr32/dl-startup.h
332 + * Architecture specific code used by dl-startup.c
334 + * Copyright (C) 2005-2007 Atmel Corporation
336 + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
339 +/* This is the library loader's main entry point. Let _dl_boot2 do its
340 + * initializations and jump to the application's entry point
343 + " .global _start\n"
344 + " .type _start,@function\n"
346 + /* All arguments are on the stack initially */
348 + " rcall _dl_start\n"
349 + /* Returns user entry point in r12. Save it. */
351 + /* We're PIC, so get the Global Offset Table */
352 + " lddpc r6, .L_GOT\n"
355 + /* Adjust argc and argv according to _dl_skip_args */
356 + " ld.w r1, r6[_dl_skip_args@got]\n"
357 + " ld.w r1, r1[0]\n"
360 + " add sp, sp, r1 << 2\n"
362 + /* Load the finalizer function */
363 + " ld.w r12, r6[_dl_fini@got]\n"
364 + /* Jump to the user's entry point */
369 + " .long .L_RGOT - _GLOBAL_OFFSET_TABLE_\n"
370 + " .size _start, . - _start\n"
373 +/* Get a pointer to the argv array. On many platforms this can be just
374 + * the address if the first argument, on other platforms we need to
375 + * do something a little more subtle here. */
376 +#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *)ARGS + 1)
379 +/* We can't call functions before the GOT has been initialized */
380 +#define NO_FUNCS_BEFORE_BOOTSTRAP
383 + * Relocate the GOT during dynamic loader bootstrap. This will add
384 + * the load address to all entries in the GOT, which is necessary
385 + * because the linker doesn't generate R_AVR32_RELATIVE relocs for the
388 +static __always_inline
389 +void PERFORM_BOOTSTRAP_GOT(struct elf_resolve *tpnt)
391 + Elf32_Addr i, nr_got;
392 + register Elf32_Addr *__r6 __asm__("r6");
393 + Elf32_Addr *got = __r6;
395 + nr_got = tpnt->dynamic_info[DT_AVR32_GOTSZ_IDX] / sizeof(*got);
396 + for (i = 2; i < nr_got; i++)
397 + got[i] += tpnt->loadaddr;
400 +#define PERFORM_BOOTSTRAP_GOT(tpnt) PERFORM_BOOTSTRAP_GOT(tpnt)
402 +/* Handle relocation of the symbols in the dynamic loader. */
403 +static __always_inline
404 +void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
405 + unsigned long symbol_addr,
406 + unsigned long load_addr, Elf32_Sym *symtab)
408 + switch(ELF32_R_TYPE(rpnt->r_info)) {
411 + case R_AVR32_GLOB_DAT:
412 + case R_AVR32_JMP_SLOT:
413 + *reloc_addr = symbol_addr;
415 + case R_AVR32_RELATIVE:
416 + SEND_STDERR_DEBUG("Applying RELATIVE relocation: ");
417 + SEND_ADDRESS_STDERR_DEBUG(load_addr, 0);
418 + SEND_STDERR_DEBUG(" + ");
419 + SEND_ADDRESS_STDERR_DEBUG(rpnt->r_addend, 1);
420 + *reloc_addr = load_addr + rpnt->r_addend;
423 + SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc_type ");
424 + SEND_NUMBER_STDERR(ELF32_R_TYPE(rpnt->r_info), 1);
425 + SEND_STDERR("REL, SYMBOL, LOAD: ");
426 + SEND_ADDRESS_STDERR(reloc_addr, 0);
428 + SEND_ADDRESS_STDERR(symbol_addr, 0);
430 + SEND_ADDRESS_STDERR(load_addr, 1);
435 +/* Transfer control to the user's application, once the dynamic loader
436 + * is done. This routine has to exit the current function, then call
437 + * the _dl_elf_main function.
439 + * Since our _dl_boot will simply call whatever is returned by
440 + * _dl_boot2, we can just return the address we're supposed to
442 +#define START() return _dl_elf_main;
444 +++ b/ldso/ldso/avr32/dl-syscalls.h
446 +/* We can't use the real errno in ldso, since it has not yet
447 + * been dynamicly linked in yet. */
448 +#include "sys/syscall.h"
449 +extern int _dl_errno;
451 +#define __set_errno(X) {(_dl_errno) = (X);}
453 +++ b/ldso/ldso/avr32/dl-sysdep.h
456 + * Various assembly language/system dependent hacks that are required
457 + * so that we can minimize the amount of platform specific code.
459 + * Copyright (C) 2004-2007 Atmel Corporation
461 + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
464 +/* Define this if the system uses RELOCA. */
465 +#define ELF_USES_RELOCA
470 +#define DT_AVR32_GOTSZ_IDX (DT_NUM + OS_NUM)
472 +#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \
474 + if (dpnt->d_tag == DT_AVR32_GOTSZ) \
475 + dynamic[DT_AVR32_GOTSZ_IDX] = dpnt->d_un.d_val; \
478 +/* Initialization sequence for the application/library GOT. */
479 +#define INIT_GOT(GOT_BASE,MODULE) \
481 + unsigned long i, nr_got; \
483 + GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \
484 + GOT_BASE[1] = (unsigned long) MODULE; \
486 + /* Add load address displacement to all GOT entries */ \
487 + nr_got = MODULE->dynamic_info[DT_AVR32_GOTSZ_IDX] / 4; \
488 + for (i = 2; i < nr_got; i++) \
489 + GOT_BASE[i] += (unsigned long)MODULE->loadaddr; \
492 +#define do_rem(result, n, base) ((result) = (n) % (base))
494 +/* Here we define the magic numbers that this dynamic loader should accept */
495 +#define MAGIC1 EM_AVR32
498 +/* Used for error messages */
499 +#define ELF_TARGET "AVR32"
501 +unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
503 +/* 4096 bytes alignment */
504 +#define PAGE_ALIGN 0xfffff000
505 +#define ADDR_ALIGN 0xfff
506 +#define OFFS_ALIGN 0x7ffff000
508 +#define elf_machine_type_class(type) \
509 + ((type == R_AVR32_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)
511 +/* AVR32 doesn't need any COPY relocs */
512 +#define DL_NO_COPY_RELOCS
514 +/* Return the link-time address of _DYNAMIC. Conveniently, this is the
515 + first element of the GOT. This must be inlined in a function which
516 + uses global data. */
517 +static inline Elf32_Addr
518 +elf_machine_dynamic (void)
520 + register Elf32_Addr *got asm ("r6");
524 +/* Return the run-time load address of the shared object. */
525 +static inline Elf32_Addr
526 +elf_machine_load_address (void)
528 + extern void __dl_start asm("_dl_start");
529 + Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
530 + Elf32_Addr pcrel_addr;
532 + asm (" lddpc %0, 2f\n"
536 + "2: .long _dl_start - 1b\n"
538 + : "=r"(pcrel_addr) : : "cc");
540 + return pcrel_addr - got_addr;
544 + * Perform any RELATIVE relocations specified by DT_RELCOUNT.
545 + * Currently, we don't use that tag, but we might in the future as
546 + * this would reduce the startup time somewhat (although probably not by much).
549 +elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
550 + Elf32_Word relative_count)
552 + Elf32_Rela *rpnt = (void *)rel_addr;
555 + Elf32_Addr *reloc_addr;
556 + reloc_addr = (void *)(load_off + (rpnt++)->r_offset);
557 + *reloc_addr = load_off + rpnt->r_addend;
558 + } while (--relative_count);
561 +++ b/ldso/ldso/avr32/elfinterp.c
564 + * AVR32 ELF shared library loader suppport
566 + * Copyright (C) 2004-2006 Atmel Corporation
568 + * All rights reserved.
570 + * Redistribution and use in source and binary forms, with or without
571 + * modification, are permitted provided that the following conditions
573 + * 1. Redistributions of source code must retain the above copyright
574 + * notice, this list of conditions and the following disclaimer.
575 + * 2. The name of the above contributors may not be
576 + * used to endorse or promote products derived from this software
577 + * without specific prior written permission.
579 + * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
580 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
581 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
582 + * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
583 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
584 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
585 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
586 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
587 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
588 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
592 +unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got)
594 + struct elf_resolve *tpnt = (struct elf_resolve *)got[1];
596 + unsigned long local_gotno;
597 + unsigned long gotsym;
598 + unsigned long new_addr;
599 + char *strtab, *symname;
600 + unsigned long *entry;
601 + unsigned long sym_index = got_offset / 4;
604 + local_gotno = tpnt->dynamic_info[DT_AVR32_LOCAL_GOTNO];
605 + gotsym = tpnt->dynamic_info[DT_AVR32_GOTSYM];
607 + sym = ((Elf32_Sym *)(tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr))
609 + strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
610 + symname = strtab + sym->st_name;
613 + new_addr = (unsigned long) _dl_find_hash(strtab + sym->st_name,
614 + tpnt->symbol_scope, tpnt,
618 + entry = (unsigned long *)(got + local_gotno + sym_index - gotsym);
626 +_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
627 + unsigned long rel_addr, unsigned long rel_size,
628 + int (*reloc_func)(struct elf_resolve *tpnt, struct dyn_elf *scope,
629 + Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab))
636 + rpnt = (Elf32_Rela *)rel_addr;
637 + rel_size /= sizeof(Elf32_Rela);
638 + symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
639 + strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
641 + for (i = 0; i < rel_size; i++, rpnt++) {
642 + int symtab_index, res;
644 + symtab_index = ELF32_R_SYM(rpnt->r_info);
646 + debug_sym(symtab, strtab, symtab_index);
647 + debug_reloc(symtab, strtab, rpnt);
649 + res = reloc_func(tpnt, scope, rpnt, symtab, strtab);
654 + _dl_dprintf(2, "\n%s: ", _dl_progname);
657 + _dl_dprintf(2, "symbol '%s': ",
658 + strtab + symtab[symtab_index].st_name);
661 + int reloc_type = ELF32_R_TYPE(rpnt->r_info);
662 +#if defined(__SUPPORT_LD_DEBUG__)
663 + _dl_dprintf(2, "can't handle reloc type %s\n",
664 + _dl_reltypes(reloc_type));
666 + _dl_dprintf(2, "can't handle reloc type %x\n",
671 + _dl_dprintf(2, "can't resolve symbol\n");
679 +static int _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
680 + Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab)
685 + unsigned long *reloc_addr;
686 + unsigned long symbol_addr;
687 +#if defined(__SUPPORT_LD_DEBUG__)
688 + unsigned long old_val;
691 + reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
692 + reloc_type = ELF32_R_TYPE(rpnt->r_info);
693 + symtab_index = ELF32_R_SYM(rpnt->r_info);
695 + symname = strtab + symtab[symtab_index].st_name;
697 + if (symtab_index) {
698 + symbol_addr = (unsigned long)
699 + _dl_find_hash(strtab + symtab[symtab_index].st_name,
700 + tpnt->symbol_scope, tpnt,
701 + elf_machine_type_class(reloc_type));
703 + /* Allow undefined references to weak symbols */
704 + if (!symbol_addr &&
705 + ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
706 + _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
707 + _dl_progname, symname);
712 +#if defined(__SUPPORT_LD_DEBUG__)
713 + old_val = *reloc_addr;
715 + switch (reloc_type) {
718 + case R_AVR32_GLOB_DAT:
719 + case R_AVR32_JMP_SLOT:
720 + *reloc_addr = symbol_addr + rpnt->r_addend;
722 + case R_AVR32_RELATIVE:
723 + *reloc_addr = (unsigned long)tpnt->loadaddr
730 +#if defined(__SUPPORT_LD_DEBUG__)
731 + if (_dl_debug_reloc && _dl_debug_detail)
732 + _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
733 + old_val, *reloc_addr);
739 +void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
740 + unsigned long rel_addr,
741 + unsigned long rel_size)
743 + /* TODO: Might want to support this in order to get faster
744 + * startup times... */
747 +int _dl_parse_relocation_information(struct dyn_elf *rpnt,
748 + unsigned long rel_addr,
749 + unsigned long rel_size)
751 + return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size,
755 +++ b/ldso/ldso/avr32/resolve.S
758 + * Linux dynamic resolving code for AVR32. Fixes up the GOT entry as
759 + * indicated in register r12 and jumps to the resolved address.
761 + * This file is subject to the terms and conditions of the GNU Lesser General
762 + * Public License. See the file "COPYING.LIB" in the main directory of this
763 + * archive for more details.
765 + * Copyright (C) 2004-2007 Atmel Corporation
771 + .global _dl_linux_resolve
772 + .type _dl_linux_resolve,@function
774 + /* The PLT code pushed r8 for us. It contains the address of this
775 + function's GOT entry, that is entry 0. ip contains the address
776 + of the GOT entry of the function we wanted to call. */
777 + stm --sp, r9-r12, lr
780 + rcall _dl_linux_resolver
784 + .size _dl_linux_resolve, . - _dl_linux_resolve
785 --- a/ldso/ldso/dl-startup.c
786 +++ b/ldso/ldso/dl-startup.c
787 @@ -217,7 +217,9 @@ DL_START(unsigned long args)
788 /* some arches (like MIPS) we have to tweak the GOT before relocations */
789 PERFORM_BOOTSTRAP_GOT(tpnt);
794 +#if !defined(PERFORM_BOOTSTRAP_GOT) || defined(__avr32__)
796 /* OK, now do the relocations. We do not do a lazy binding here, so
797 that once we are done, we have considerably more flexibility. */
798 --- a/libc/inet/resolv.c
799 +++ b/libc/inet/resolv.c
800 @@ -1643,7 +1643,7 @@ int attribute_hidden __read_etc_hosts_r(
803 #ifdef __UCLIBC_HAS_IPV6__
804 - } else if (type == AF_INET6 && inet_pton(AF_INET6, alias[0], in6) > 0) {
805 + } else if (type == AF_INET6 && inet_pton(AF_INET6, alias[0], in6) > 0) {
806 DPRINTF("Found INET6\n");
809 @@ -1658,8 +1658,8 @@ int attribute_hidden __read_etc_hosts_r(
813 - break; /* bad ip address */
815 + continue; /* bad ip address, keep searching */
818 if (action!=GETHOSTENT) {
821 +++ b/libc/string/avr32/Makefile
823 +# Makefile for uClibc
825 +# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
827 +# This program is free software; you can redistribute it and/or modify it under
828 +# the terms of the GNU Library General Public License as published by the Free
829 +# Software Foundation; either version 2 of the License, or (at your option) any
832 +# This program is distributed in the hope that it will be useful, but WITHOUT
833 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
834 +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
837 +# You should have received a copy of the GNU Library General Public License
838 +# along with this program; if not, write to the Free Software Foundation, Inc.,
839 +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
841 +top_srcdir := ../../../
842 +top_builddir := ../../../
846 +include $(top_builddir)Rules.mak
847 +include ../Makefile.in
848 +include $(top_srcdir)Makerules
850 +++ b/libc/string/avr32/bcopy.S
853 + * Copyright (C) 2004-2007 Atmel Corporation
855 + * This file is subject to the terms and conditions of the GNU Lesser General
856 + * Public License. See the file "COPYING.LIB" in the main directory of this
857 + * archive for more details.
860 +#include <features.h>
862 +#ifdef __UCLIBC_SUSV3_LEGACY__
866 + .type bcopy, @function
869 + /* Swap the first two arguments */
875 + .size bcopy, . - bcopy
877 +#endif /* __UCLIBC_SUSV3_LEGACY__ */
879 +++ b/libc/string/avr32/bzero.S
882 + * Copyright (C) 2004-2007 Atmel Corporation
884 + * This file is subject to the terms and conditions of the GNU Lesser General
885 + * Public License. See the file "COPYING.LIB" in the main directory of this
886 + * archive for more details.
889 +#ifdef __UCLIBC_SUSV3_LEGACY__
893 + .type bzero, @function
900 + .size bzero, . - bzero
902 +#endif /* __UCLIBC_SUSV3_LEGACY__ */
904 +++ b/libc/string/avr32/memcmp.S
907 + * Copyright (C) 2004-2007 Atmel Corporation
909 + * This file is subject to the terms and conditions of the GNU Lesser General
910 + * Public License. See the file "COPYING.LIB" in the main directory of this
911 + * archive for more details.
914 +#include <features.h>
922 + .type memcmp, @function
951 +2: bfextu r11, r9, 24, 8
952 + bfextu r12, r8, 24, 8
961 + .size memcmp, . - memcmp
963 +libc_hidden_def(memcmp)
964 +#ifdef __UCLIBC_SUSV3_LEGACY__
965 +strong_alias(memcmp,bcmp)
968 +++ b/libc/string/avr32/memcpy.S
971 + * Copyright (C) 2004-2007 Atmel Corporation
973 + * This file is subject to the terms and conditions of the GNU Lesser General
974 + * Public License. See the file "COPYING.LIB" in the main directory of this
975 + * archive for more details.
978 +/* Don't use r12 as dst since we must return it unmodified */
985 + .type memcpy, @function
990 + /* If we have less than 32 bytes, don't do anything fancy */
992 + brge .Lmore_than_31
1005 + /* Check alignment */
1008 + brne .Lunaligned_src
1011 + brne .Lunaligned_dst
1015 + brlt .Lless_than_32
1017 +1: /* Copy 32 bytes at a time */
1026 + /* Copy 16 more bytes if possible */
1028 + brlt .Lless_than_16
1036 + /* Do the remaining as byte copies */
1038 + add pc, pc, len << 2
1047 + /* Make src cacheline-aligned. r8 = (src & 31) */
1055 + /* If dst is word-aligned, we're ready to go */
1059 + breq .Laligned_copy
1062 + /* src is aligned, but dst is not. Expect bad performance */
1071 + add pc, pc, len << 2
1078 + .size memcpy, . - memcpy
1080 +libc_hidden_def(memcpy)
1082 +++ b/libc/string/avr32/memmove.S
1085 + * Copyright (C) 2004-2007 Atmel Corporation
1087 + * This file is subject to the terms and conditions of the GNU Lesser General
1088 + * Public License. See the file "COPYING.LIB" in the main directory of this
1089 + * archive for more details.
1098 + .type memmove, @function
1108 + * The rest is basically the same as in memcpy.S except that
1109 + * the direction is reversed.
1112 + brge .Lmore_than_31
1125 + /* Check alignment */
1128 + brne .Lunaligned_src
1131 + brne .Lunaligned_dst
1135 + brlt .Lless_than_32
1137 +1: /* Copy 32 bytes at a time */
1146 + /* Copy 16 more bytes if possible */
1148 + brlt .Lless_than_16
1156 + /* Do the remaining as byte copies */
1167 + /* Make src cacheline-aligned. r8 = (src & 31) */
1174 + /* If dst is word-aligned, we're ready to go */
1178 + breq .Laligned_copy
1181 + /* src is aligned, but dst is not. Expect bad performance */
1190 + add pc, pc, len << 2
1197 + .size memmove, . - memmove
1199 +libc_hidden_def(memmove)
1201 +++ b/libc/string/avr32/memset.S
1204 + * Copyright (C) 2004-2007 Atmel Corporation
1206 + * This file is subject to the terms and conditions of the GNU Lesser General
1207 + * Public License. See the file "COPYING.LIB" in the main directory of this
1208 + * archive for more details.
1211 +#include <features.h>
1219 + .type memset, @function
1223 + .type __memset, @function
1230 + brge .Llarge_memset
1243 + bfins r8, r8, 8, 8
1244 + bfins r8, r8, 16, 16
1261 + /* If we are done, n == -8 and we'll skip all st.b insns below */
1270 + .size memset, . - memset
1272 +libc_hidden_def(memset)
1274 +++ b/libc/string/avr32/strcmp.S
1277 + * Copyright (C) 2004-2007 Atmel Corporation
1279 + * This file is subject to the terms and conditions of the GNU Lesser General
1280 + * Public License. See the file "COPYING.LIB" in the main directory of this
1281 + * archive for more details.
1284 +#include <features.h>
1292 + .type strcmp, @function
1297 + brne .Lunaligned_s1
1299 + brne .Lunaligned_s2
1309 +2: bfextu r12, r8, 24, 8
1310 + bfextu r11, r9, 24, 8
1315 + bfextu r12, r8, 16, 8
1316 + bfextu r11, r9, 16, 8
1321 + bfextu r12, r8, 8, 8
1322 + bfextu r11, r9, 8, 8
1327 + bfextu r12, r8, 0, 8
1328 + bfextu r11, r9, 0, 8
1348 + * s1 and s2 can't both be aligned, and unaligned word loads
1349 + * can trigger spurious exceptions if we cross a page boundary.
1350 + * Do it the slow way...
1360 + .size strcmp, . - strcmp
1362 +libc_hidden_def(strcmp)
1363 +#ifndef __UCLIBC_HAS_LOCALE__
1364 +strong_alias(strcmp, strcoll)
1365 +libc_hidden_def(strcoll)
1368 +++ b/libc/string/avr32/strlen.S
1371 + * Copyright (C) 2004-2007 Atmel Corporation
1373 + * This file is subject to the terms and conditions of the GNU Lesser General
1374 + * Public License. See the file "COPYING.LIB" in the main directory of this
1375 + * archive for more details.
1378 +#include <features.h>
1384 + .type strlen, @function
1390 + brne .Lunaligned_str
1397 + bfextu r9, r8, 24, 8
1401 + bfextu r9, r8, 16, 8
1405 + bfextu r9, r8, 8, 8
1413 + add pc, pc, r9 << 3
1414 + sub r0, r0, 0 /* 4-byte nop */
1429 + .size strlen, . - strlen
1431 +libc_hidden_def(strlen)
1433 +++ b/libc/sysdeps/linux/avr32/Makefile
1435 +# Makefile for uClibc
1437 +# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
1439 +# This program is free software; you can redistribute it and/or modify it under
1440 +# the terms of the GNU Library General Public License as published by the Free
1441 +# Software Foundation; either version 2 of the License, or (at your option) any
1444 +# This program is distributed in the hope that it will be useful, but WITHOUT
1445 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1446 +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
1449 +# You should have received a copy of the GNU Library General Public License
1450 +# along with this program; if not, write to the Free Software Foundation, Inc.,
1451 +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1453 +top_srcdir=../../../../
1454 +top_builddir=../../../../
1457 +include $(top_builddir)Rules.mak
1458 +include Makefile.arch
1459 +include $(top_srcdir)Makerules
1461 +++ b/libc/sysdeps/linux/avr32/Makefile.arch
1463 +# Makefile for uClibc
1465 +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
1467 +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
1470 +CSRC := brk.c clone.c mmap.c sigaction.c
1472 +SSRC := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
1473 + sigrestorer.S syscall.S vfork.S
1475 +include $(top_srcdir)/libc/sysdeps/linux/Makefile.commonarch
1477 +++ b/libc/sysdeps/linux/avr32/__longjmp.S
1480 + * Copyright (C) 2004-2007 Atmel Corporation
1482 + * This file is subject to the terms and conditions of the GNU Lesser General
1483 + * Public License. See the file "COPYING.LIB" in the main directory of this
1484 + * archive for more details.
1488 + .type __longjmp,"function"
1491 + ldm r12++, r0-r8,sp,lr
1492 + mustr r8 /* restore status register (lower half) */
1493 + cp r11, 0 /* can't return zero */
1497 + .size __longjmp, . - __longjmp
1499 +libc_hidden_def(__longjmp)
1501 +++ b/libc/sysdeps/linux/avr32/bits/atomic.h
1504 + * Copyright (C) 2007 Atmel Corporation
1506 + * This file is subject to the terms and conditions of the GNU Lesser General
1507 + * Public License. See the file "COPYING.LIB" in the main directory of this
1508 + * archive for more details.
1510 +#ifndef _AVR32_BITS_ATOMIC_H
1511 +#define _AVR32_BITS_ATOMIC_H 1
1513 +#include <inttypes.h>
1515 +typedef int32_t atomic32_t;
1516 +typedef uint32_t uatomic32_t;
1517 +typedef int_fast32_t atomic_fast32_t;
1518 +typedef uint_fast32_t uatomic_fast32_t;
1520 +typedef intptr_t atomicptr_t;
1521 +typedef uintptr_t uatomicptr_t;
1522 +typedef intmax_t atomic_max_t;
1523 +typedef uintmax_t uatomic_max_t;
1525 +#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
1528 +#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
1531 +#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
1533 + __typeof__(*(mem)) __prev; \
1534 + __asm__ __volatile__( \
1535 + "/* __arch_compare_and_exchange_val_32_acq */\n" \
1537 + " ld.w %[result], %[m]\n" \
1538 + " cp.w %[result], %[old]\n" \
1540 + " stcond %[m], %[new]\n" \
1543 + : [result] "=&r"(__result), [m] "=m"(*(mem)) \
1544 + : "m"(*(mem)), [old] "ir"(oldval), \
1545 + [new] "r"(newval) \
1546 + : "memory", "cc"); \
1550 +#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
1553 +#define __arch_exchange_32_acq(mem, newval) \
1555 + __typeof__(*(mem)) __oldval; \
1556 + __asm__ __volatile__( \
1557 + "/*__arch_exchange_32_acq */\n" \
1558 + " xchg %[old], %[m], %[new]" \
1559 + : [old] "=&r"(__oldval) \
1560 + : [m] "r"(mem), [new] "r"(newval) \
1565 +#define __arch_atomic_exchange_and_add_32(mem, value) \
1567 + __typeof__(*(mem)) __oldval, __tmp; \
1568 + __asm__ __volatile__( \
1569 + "/* __arch_atomic_exchange_and_add_32 */\n" \
1571 + " ld.w %[old], %[m]\n" \
1572 + " add %[tmp], %[old], %[val]\n" \
1573 + " stcond %[m], %[tmp]\n" \
1575 + : [old] "=&r"(__oldval), [tmp] "=&r"(__tmp), \
1576 + [m] "=m"(*(mem)) \
1577 + : "m"(*(mem)), [val] "r"(value) \
1578 + : "memory", "cc"); \
1582 +#define __arch_atomic_decrement_if_positive_32(mem) \
1584 + __typeof__(*(mem)) __oldval, __tmp; \
1585 + __asm__ __volatile__( \
1586 + "/* __arch_atomic_decrement_if_positive_32 */\n" \
1588 + " ld.w %[old], %[m]\n" \
1589 + " sub %[tmp], %[old], 1\n" \
1591 + " stcond %[m], %[tmp]\n" \
1594 + : [old] "=&r"(__oldval), [tmp] "=&r"(__tmp), \
1595 + [m] "=m"(*(mem)) \
1597 + : "memory", "cc"); \
1601 +#define atomic_exchange_acq(mem, newval) \
1603 + if (sizeof(*(mem)) != 4) \
1605 + __arch_exchange_32_acq(mem, newval); \
1608 +#define atomic_exchange_and_add(mem, newval) \
1610 + if (sizeof(*(mem)) != 4) \
1612 + __arch_atomic_exchange_and_add_32(mem, newval); \
1615 +#define atomic_decrement_if_positive(mem) \
1617 + if (sizeof(*(mem)) != 4) \
1619 + __arch_atomic_decrement_if_positive_32(mem); \
1622 +#endif /* _AVR32_BITS_ATOMIC_H */
1624 +++ b/libc/sysdeps/linux/avr32/bits/byteswap.h
1627 + * Copyright (C) 2005 Atmel Corporation
1629 + * This file is subject to the terms and conditions of the GNU Lesser General
1630 + * Public License. See the file "COPYING.LIB" in the main directory of this
1631 + * archive for more details.
1634 +#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
1635 +# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
1638 +#ifndef _BITS_BYTESWAP_H
1639 +#define _BITS_BYTESWAP_H 1
1641 +/* Swap bytes in 16 bit value. */
1642 +#if defined __GNUC__
1643 +# define __bswap_16(x) (__extension__ __builtin_bswap_16(x))
1645 +/* This is better than nothing. */
1646 +static __inline unsigned short int
1647 +__bswap_16 (unsigned short int __bsx)
1649 + return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
1653 +/* Swap bytes in 32 bit value. */
1654 +#if defined __GNUC__
1655 +# define __bswap_32(x) (__extension__ __builtin_bswap_32(x))
1657 +static __inline unsigned int
1658 +__bswap_32 (unsigned int __bsx)
1660 + return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
1661 + (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
1665 +#if defined __GNUC__
1666 +/* Swap bytes in 64 bit value. */
1667 +# define __bswap_constant_64(x) \
1668 + ((((x) & 0xff00000000000000ull) >> 56) \
1669 + | (((x) & 0x00ff000000000000ull) >> 40) \
1670 + | (((x) & 0x0000ff0000000000ull) >> 24) \
1671 + | (((x) & 0x000000ff00000000ull) >> 8) \
1672 + | (((x) & 0x00000000ff000000ull) << 8) \
1673 + | (((x) & 0x0000000000ff0000ull) << 24) \
1674 + | (((x) & 0x000000000000ff00ull) << 40) \
1675 + | (((x) & 0x00000000000000ffull) << 56))
1677 +# define __bswap_64(x) \
1681 + __extension__ unsigned long long int __ll; \
1682 + unsigned int __l[2]; \
1684 + if (__builtin_constant_p(x)) \
1685 + __r.__ll = __bswap_constant_64(x); \
1688 + __r.__l[0] = __bswap_32(__w.__l[1]); \
1689 + __r.__l[1] = __bswap_32(__w.__l[0]); \
1695 +#endif /* _BITS_BYTESWAP_H */
1697 +++ b/libc/sysdeps/linux/avr32/bits/endian.h
1699 +/* AVR32 is big-endian */
1702 +# error "Never use <bits/endian.h> directly; include <endian.h> instead."
1705 +#define __BYTE_ORDER __BIG_ENDIAN
1707 +++ b/libc/sysdeps/linux/avr32/bits/fcntl.h
1710 +# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
1713 +#include <sys/types.h>
1716 + * open/fcntl - O_SYNC is only implemented on blocks devices and on files
1717 + * located on an ext2 file system
1719 +#define O_ACCMODE 00000003
1720 +#define O_RDONLY 00000000
1721 +#define O_WRONLY 00000001
1722 +#define O_RDWR 00000002
1723 +#define O_CREAT 00000100 /* not fcntl */
1724 +#define O_EXCL 00000200 /* not fcntl */
1725 +#define O_NOCTTY 00000400 /* not fcntl */
1726 +#define O_TRUNC 00001000 /* not fcntl */
1727 +#define O_APPEND 00002000
1728 +#define O_NONBLOCK 00004000
1729 +#define O_NDELAY O_NONBLOCK
1730 +#define O_SYNC 00010000
1731 +#define O_ASYNC 00020000
1734 +# define O_DIRECT 00040000 /* must be a directory */
1735 +# define O_DIRECTORY 00200000 /* direct disk access */
1736 +# define O_NOFOLLOW 00400000 /* don't follow links */
1737 +# define O_NOATIME 01000000 /* don't set atime */
1740 +#ifdef __USE_LARGEFILE64
1741 +# define O_LARGEFILE 00100000
1744 +/* For now Linux has synchronisity options for data and read operations.
1745 + We define the symbols here but let them do the same as O_SYNC since
1746 + this is a superset. */
1747 +#if defined __USE_POSIX199309 || defined __USE_UNIX98
1748 +# define O_DSYNC O_SYNC /* Synchronize data. */
1749 +# define O_RSYNC O_SYNC /* Synchronize read operations. */
1752 +#define F_DUPFD 0 /* dup */
1753 +#define F_GETFD 1 /* get close_on_exec */
1754 +#define F_SETFD 2 /* set/clear close_on_exec */
1755 +#define F_GETFL 3 /* get file->f_flags */
1756 +#define F_SETFL 4 /* set file->f_flags */
1758 +#ifndef __USE_FILE_OFFSET64
1761 +# define F_SETLKW 7
1763 +# define F_GETLK F_GETLK64
1764 +# define F_SETLK F_SETLK64
1765 +# define F_SETLKW F_SETLKW64
1767 +#define F_GETLK64 12 /* using 'struct flock64' */
1768 +#define F_SETLK64 13
1769 +#define F_SETLKW64 14
1771 +#if defined __USE_BSD || defined __USE_XOPEN2K
1772 +# define F_SETOWN 8 /* for sockets. */
1773 +# define F_GETOWN 9 /* for sockets. */
1777 +# define F_SETSIG 10 /* for sockets. */
1778 +# define F_GETSIG 11 /* for sockets. */
1782 +# define F_SETLEASE 1024 /* Set a lease. */
1783 +# define F_GETLEASE 1025 /* Enquire what lease is active. */
1784 +# define F_NOTIFY 1026 /* Request notfications on a directory. */
1787 +/* for F_[GET|SET]FL */
1788 +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
1790 +/* for posix fcntl() and lockf() */
1795 +/* for old implementation of bsd flock () */
1796 +#define F_EXLCK 4 /* or 3 */
1797 +#define F_SHLCK 8 /* or 4 */
1800 +#define F_INPROGRESS 16
1803 +/* operations for bsd flock(), also used by the kernel implementation */
1804 +# define LOCK_SH 1 /* shared lock */
1805 +# define LOCK_EX 2 /* exclusive lock */
1806 +# define LOCK_NB 4 /* or'd with one of the above to prevent
1808 +# define LOCK_UN 8 /* remove lock */
1812 +# define LOCK_MAND 32 /* This is a mandatory flock */
1813 +# define LOCK_READ 64 /* ... Which allows concurrent
1814 + read operations */
1815 +# define LOCK_WRITE 128 /* ... Which allows concurrent
1816 + write operations */
1817 +# define LOCK_RW 192 /* ... Which allows concurrent
1818 + read & write ops */
1822 +/* Types of directory notifications that may be requested with F_NOTIFY. */
1823 +# define DN_ACCESS 0x00000001 /* File accessed. */
1824 +# define DN_MODIFY 0x00000002 /* File modified. */
1825 +# define DN_CREATE 0x00000004 /* File created. */
1826 +# define DN_DELETE 0x00000008 /* File removed. */
1827 +# define DN_RENAME 0x00000010 /* File renamed. */
1828 +# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
1829 +# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
1835 +#ifndef __USE_FILE_OFFSET64
1839 + __off64_t l_start;
1845 +#ifdef __USE_LARGEFILE64
1849 + __off64_t l_start;
1855 +/* Define some more compatibility macros to be backward compatible with
1856 + * BSD systems which did not managed to hide these kernel macros. */
1858 +# define FAPPEND O_APPEND
1859 +# define FFSYNC O_FSYNC
1860 +# define FASYNC O_ASYNC
1861 +# define FNONBLOCK O_NONBLOCK
1862 +# define FNDELAY O_NDELAY
1863 +#endif /* Use BSD. */
1865 +/* Advise to `posix_fadvise'. */
1866 +#ifdef __USE_XOPEN2K
1867 +# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
1868 +# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
1869 +# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
1870 +# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
1871 +# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
1872 +# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
1875 +++ b/libc/sysdeps/linux/avr32/bits/kernel_stat.h
1877 +#ifndef _BITS_STAT_STRUCT_H
1878 +#define _BITS_STAT_STRUCT_H
1881 +#error bits/kernel_stat.h is for internal uClibc use only!
1885 + * This file provides struct stat, taken from kernel 2.6.4. Verified
1886 + * to match kernel 2.6.22.
1889 +struct kernel_stat {
1890 + unsigned long st_dev;
1891 + unsigned long st_ino;
1892 + unsigned short st_mode;
1893 + unsigned short st_nlink;
1894 + unsigned short st_uid;
1895 + unsigned short st_gid;
1896 + unsigned long st_rdev;
1897 + unsigned long st_size;
1898 + unsigned long st_blksize;
1899 + unsigned long st_blocks;
1900 + unsigned long st_atime;
1901 + unsigned long st_atime_nsec;
1902 + unsigned long st_mtime;
1903 + unsigned long st_mtime_nsec;
1904 + unsigned long st_ctime;
1905 + unsigned long st_ctime_nsec;
1906 + unsigned long __unused4;
1907 + unsigned long __unused5;
1910 +#define STAT_HAVE_NSEC 1
1912 +struct kernel_stat64 {
1913 + unsigned long long st_dev;
1915 + unsigned long long st_ino;
1916 + unsigned int st_mode;
1917 + unsigned int st_nlink;
1919 + unsigned long st_uid;
1920 + unsigned long st_gid;
1922 + unsigned long long st_rdev;
1924 + long long st_size;
1925 + unsigned long __pad1;
1926 + unsigned long st_blksize;
1928 + unsigned long long st_blocks;
1930 + unsigned long st_atime;
1931 + unsigned long st_atime_nsec;
1933 + unsigned long st_mtime;
1934 + unsigned long st_mtime_nsec;
1936 + unsigned long st_ctime;
1937 + unsigned long st_ctime_nsec;
1939 + unsigned long __unused1;
1940 + unsigned long __unused2;
1943 +#endif /* _BITS_STAT_STRUCT_H */
1945 +++ b/libc/sysdeps/linux/avr32/bits/kernel_types.h
1947 +/* Note that we use the exact same include guard #define names
1948 + * as asm/posix_types.h. This will avoid gratuitous conflicts
1949 + * with the posix_types.h kernel header, and will ensure that
1950 + * our private content, and not the kernel header, will win.
1953 +#ifndef __ASM_AVR32_POSIX_TYPES_H
1954 +#define __ASM_AVR32_POSIX_TYPES_H
1957 + * This file is generally used by user-level software, so you need to
1958 + * be a little careful about namespace pollution etc. Also, we cannot
1959 + * assume GCC is being used.
1962 +typedef unsigned long __kernel_dev_t;
1963 +typedef unsigned long __kernel_ino_t;
1964 +typedef unsigned short __kernel_mode_t;
1965 +typedef unsigned short __kernel_nlink_t;
1966 +typedef long __kernel_off_t;
1967 +typedef int __kernel_pid_t;
1968 +typedef unsigned short __kernel_ipc_pid_t;
1969 +typedef unsigned int __kernel_uid_t;
1970 +typedef unsigned int __kernel_gid_t;
1971 +typedef unsigned long __kernel_size_t;
1972 +typedef long __kernel_ssize_t;
1973 +typedef int __kernel_ptrdiff_t;
1974 +typedef long __kernel_time_t;
1975 +typedef long __kernel_suseconds_t;
1976 +typedef long __kernel_clock_t;
1977 +typedef int __kernel_timer_t;
1978 +typedef int __kernel_clockid_t;
1979 +typedef int __kernel_daddr_t;
1980 +typedef char * __kernel_caddr_t;
1981 +typedef unsigned short __kernel_uid16_t;
1982 +typedef unsigned short __kernel_gid16_t;
1983 +typedef unsigned int __kernel_uid32_t;
1984 +typedef unsigned int __kernel_gid32_t;
1985 +typedef unsigned short __kernel_old_uid_t;
1986 +typedef unsigned short __kernel_old_gid_t;
1987 +typedef unsigned short __kernel_old_dev_t;
1990 +typedef long long __kernel_loff_t;
1994 +#if defined(__USE_ALL)
2001 +#endif /* __ASM_AVR32_POSIX_TYPES_H */
2003 +++ b/libc/sysdeps/linux/avr32/bits/mman.h
2005 +/* Definitions for POSIX memory map interface. Linux/AVR32 version.
2006 + Copyright (C) 1997, 2000 Free Software Foundation, Inc.
2007 + This file is part of the GNU C Library.
2009 + The GNU C Library is free software; you can redistribute it and/or
2010 + modify it under the terms of the GNU Lesser General Public
2011 + License as published by the Free Software Foundation; either
2012 + version 2.1 of the License, or (at your option) any later version.
2014 + The GNU C Library is distributed in the hope that it will be useful,
2015 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2016 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2017 + Lesser General Public License for more details.
2019 + You should have received a copy of the GNU Lesser General Public
2020 + License along with the GNU C Library; if not, write to the Free
2021 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2022 + 02111-1307 USA. */
2024 +#ifndef _SYS_MMAN_H
2025 +# error "Never include this file directly. Use <sys/mman.h> instead"
2028 +/* The following definitions basically come from the kernel headers.
2029 + But the kernel header is not namespace clean. */
2032 +/* Protections are chosen from these bits, OR'd together. The
2033 + implementation does not necessarily support PROT_EXEC or PROT_WRITE
2034 + without PROT_READ. The only guarantees are that no writing will be
2035 + allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
2037 +#define PROT_READ 0x1 /* Page can be read. */
2038 +#define PROT_WRITE 0x2 /* Page can be written. */
2039 +#define PROT_EXEC 0x4 /* Page can be executed. */
2040 +#define PROT_NONE 0x0 /* Page can not be accessed. */
2041 +#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
2042 + growsdown vma (mprotect only). */
2043 +#define PROT_GROWSUP 0x02000000 /* Extend change to start of
2044 + growsup vma (mprotect only). */
2046 +/* Sharing types (must choose one and only one of these). */
2047 +#define MAP_SHARED 0x01 /* Share changes. */
2048 +#define MAP_PRIVATE 0x02 /* Changes are private. */
2050 +# define MAP_TYPE 0x0f /* Mask for type of mapping. */
2054 +#define MAP_FIXED 0x10 /* Interpret addr exactly. */
2056 +# define MAP_FILE 0
2057 +# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
2058 +# define MAP_ANON MAP_ANONYMOUS
2061 +/* These are Linux-specific. */
2063 +# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
2064 +# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
2065 +# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
2066 +# define MAP_LOCKED 0x2000 /* Lock the mapping. */
2067 +# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
2068 +# define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
2069 +# define MAP_NONBLOCK 0x10000 /* do not block on IO */
2072 +/* Flags to `msync'. */
2073 +#define MS_ASYNC 1 /* Sync memory asynchronously. */
2074 +#define MS_SYNC 4 /* Synchronous memory sync. */
2075 +#define MS_INVALIDATE 2 /* Invalidate the caches. */
2077 +/* Flags for `mlockall'. */
2078 +#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
2079 +#define MCL_FUTURE 2 /* Lock all additions to address
2082 +/* Flags for `mremap'. */
2084 +# define MREMAP_MAYMOVE 1
2085 +# define MREMAP_FIXED 2
2088 +/* Advise to `madvise'. */
2090 +# define MADV_NORMAL 0 /* No further special treatment. */
2091 +# define MADV_RANDOM 1 /* Expect random page references. */
2092 +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
2093 +# define MADV_WILLNEED 3 /* Will need these pages. */
2094 +# define MADV_DONTNEED 4 /* Don't need these pages. */
2095 +# define MADV_REMOVE 9 /* Remove these pages and resources. */
2096 +# define MADV_DONTFORK 10 /* Do not inherit across fork. */
2097 +# define MADV_DOFORK 11 /* Do inherit across fork. */
2100 +/* The POSIX people had to invent similar names for the same things. */
2101 +#ifdef __USE_XOPEN2K
2102 +# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
2103 +# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
2104 +# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
2105 +# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
2106 +# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
2109 +++ b/libc/sysdeps/linux/avr32/bits/setjmp.h
2112 + * Copyright (C) 2004-2005 Atmel Corporation
2114 + * This file is subject to the terms and conditions of the GNU Lesser General
2115 + * Public License. See the file "COPYING.LIB" in the main directory of this
2116 + * archive for more details.
2118 +#ifndef _BITS_SETJMP_H
2119 +#define _BITS_SETJMP_H 1
2121 +#if !defined _SETJMP_H && !defined _PTHREAD_H
2122 +# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
2127 + * The jump buffer contains r0-r7, sr, sp and lr. Other registers are
2130 +typedef int __jmp_buf[11];
2133 +#define __JMP_BUF_SP 4
2135 +/* Test if longjmp to JMPBUF would unwind the frame containing a local
2136 + variable at ADDRESS. */
2137 +#define _JMPBUF_UNWINDS(jmpbuf, address) \
2138 + ((void *)(address) < (void *)(jmpbuf[__JMP_BUF_SP]))
2140 +#endif /* _BITS_SETJMP_H */
2142 +++ b/libc/sysdeps/linux/avr32/bits/stackinfo.h
2144 +/* Copyright (C) 1999 Free Software Foundation, Inc.
2145 + This file is part of the GNU C Library.
2147 + The GNU C Library is free software; you can redistribute it and/or
2148 + modify it under the terms of the GNU Lesser General Public
2149 + License as published by the Free Software Foundation; either
2150 + version 2.1 of the License, or (at your option) any later version.
2152 + The GNU C Library is distributed in the hope that it will be useful,
2153 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2154 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2155 + Lesser General Public License for more details.
2157 + You should have received a copy of the GNU Lesser General Public
2158 + License along with the GNU C Library; if not, write to the Free
2159 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2160 + 02111-1307 USA. */
2162 +/* This file contains a bit of information about the stack allocation
2163 + of the processor. */
2165 +#ifndef _STACKINFO_H
2166 +#define _STACKINFO_H 1
2168 +/* On AVR32 the stack grows down. */
2169 +#define _STACK_GROWS_DOWN 1
2171 +#endif /* stackinfo.h */
2173 +++ b/libc/sysdeps/linux/avr32/bits/syscalls.h
2175 +#ifndef _BITS_SYSCALLS_H
2176 +#define _BITS_SYSCALLS_H
2178 +# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
2182 + * This includes the `__NR_<name>' syscall numbers taken from the
2183 + * Linux kernel header files. It also defines the traditional
2184 + * `SYS_<name>' macros for older programs.
2186 +#include <bits/sysnum.h>
2188 +#ifndef __ASSEMBLER__
2192 +#define SYS_ify(syscall_name) (__NR_##syscall_name)
2195 +#define _syscall0(type,name) \
2198 + return (type)(INLINE_SYSCALL(name, 0)); \
2202 +#define _syscall1(type,name,type1,arg1) \
2203 + type name(type1 arg1) \
2205 + return (type)(INLINE_SYSCALL(name, 1, arg1)); \
2209 +#define _syscall2(type,name,type1,arg1,type2,arg2) \
2210 + type name(type1 arg1, type2 arg2) \
2212 + return (type)(INLINE_SYSCALL(name, 2, arg1, arg2)); \
2216 +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
2217 + type name(type1 arg1, type2 arg2, type3 arg3) \
2219 + return (type)(INLINE_SYSCALL(name, 3, arg1, \
2224 +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3, \
2226 + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
2228 + return (type)(INLINE_SYSCALL(name, 4, arg1, arg2, \
2233 +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3, \
2234 + type4,arg4,type5,arg5) \
2235 + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
2238 + return (type)(INLINE_SYSCALL(name, 5, arg1, arg2, \
2239 + arg3, arg4, arg5)); \
2243 +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3, \
2244 + type4,arg4,type5,arg5,type6,arg6) \
2245 + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
2246 + type5 arg5, type6 arg6) \
2248 + return (type)(INLINE_SYSCALL(name, 6, arg1, arg2, arg3, \
2249 + arg4, arg5, arg6)); \
2253 +#define unlikely(x) __builtin_expect((x), 0)
2255 +#undef INLINE_SYSCALL
2256 +#define INLINE_SYSCALL(name, nr, args...) \
2258 + unsigned _sys_result = INTERNAL_SYSCALL(name, , nr, args); \
2259 + if (unlikely(INTERNAL_SYSCALL_ERROR_P(_sys_result, ))) { \
2260 + __set_errno(INTERNAL_SYSCALL_ERRNO(_sys_result, )); \
2261 + _sys_result = (unsigned int) -1; \
2263 + (int) _sys_result; \
2266 +#undef INTERNAL_SYSCALL_DECL
2267 +#define INTERNAL_SYSCALL_DECL(err) do { } while(0)
2269 +#undef INTERNAL_SYSCALL
2270 +#define INTERNAL_SYSCALL(name, err, nr, args...) \
2272 + register int _a1 asm ("r12"); \
2273 + register int _scno asm("r8") = SYS_ify(name); \
2274 + LOAD_ARGS_##nr (args); \
2275 + asm volatile ("scall /* syscall " #name " */" \
2277 + : "r"(_scno) ASM_ARGS_##nr \
2278 + : "cc", "memory"); \
2282 +#undef INTERNAL_SYSCALL_ERROR_P
2283 +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
2284 + ((unsigned int)(val) >= 0xfffff001U)
2286 +#undef INTERNAL_SYSCALL_ERRNO
2287 +#define INTERNAL_SYSCALL_ERRNO(val, errr) (-(val))
2289 +#define LOAD_ARGS_0() do { } while(0)
2291 +#define LOAD_ARGS_1(a1) \
2292 + _a1 = (int) (a1); \
2294 +#define ASM_ARGS_1 ASM_ARGS_0, "r"(_a1)
2295 +#define LOAD_ARGS_2(a1, a2) \
2296 + register int _a2 asm("r11") = (int)(a2); \
2298 +#define ASM_ARGS_2 ASM_ARGS_1, "r"(_a2)
2299 +#define LOAD_ARGS_3(a1, a2, a3) \
2300 + register int _a3 asm("r10") = (int)(a3); \
2301 + LOAD_ARGS_2(a1, a2)
2302 +#define ASM_ARGS_3 ASM_ARGS_2, "r"(_a3)
2303 +#define LOAD_ARGS_4(a1, a2, a3, a4) \
2304 + register int _a4 asm("r9") = (int)(a4); \
2305 + LOAD_ARGS_3(a1, a2, a3)
2306 +#define ASM_ARGS_4 ASM_ARGS_3, "r"(_a4)
2307 +#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
2308 + register int _a5 asm("r5") = (int)(a5); \
2309 + LOAD_ARGS_4(a1, a2, a3, a4)
2310 +#define ASM_ARGS_5 ASM_ARGS_4, "r"(_a5)
2311 +#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
2312 + register int _a6 asm("r3") = (int)(a6); \
2313 + LOAD_ARGS_5(a1, a2, a3, a4, a5)
2314 +#define ASM_ARGS_6 ASM_ARGS_5, "r"(_a6)
2316 +#endif /* __ASSEMBLER__ */
2317 +#endif /* _BITS_SYSCALLS_H */
2319 +++ b/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h
2322 + * Track misc arch-specific features that aren't config options
2325 +#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
2326 +#define _BITS_UCLIBC_ARCH_FEATURES_H
2328 +/* instruction used when calling abort() to kill yourself */
2329 +/* trigger illegal instruction exception, same as BUG in Linux */
2330 +#define __UCLIBC_ABORT_INSTRUCTION__ ".short 0x5df0"
2332 +/* can your target use syscall6() for mmap ? */
2333 +#define __UCLIBC_MMAP_HAS_6_ARGS__
2335 +/* does your target use syscall4() for truncate64 ? (32bit arches only) */
2336 +#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
2338 +/* does your target have a broken create_module() ? */
2339 +#undef __UCLIBC_BROKEN_CREATE_MODULE__
2341 +/* does your target have to worry about older [gs]etrlimit() ? */
2342 +#undef __UCLIBC_HANDLE_OLDER_RLIMIT__
2344 +/* does your target prefix all symbols with an _ ? */
2345 +#define __UCLIBC_NO_UNDERSCORES__
2347 +/* does your target have an asm .set ? */
2348 +#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
2350 +/* define if target doesn't like .global */
2351 +#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
2353 +/* define if target supports .weak */
2354 +#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
2356 +/* define if target supports .weakext */
2357 +#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
2359 +/* needed probably only for ppc64 */
2360 +#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
2362 +/* define if target supports IEEE signed zero floats */
2363 +#define __UCLIBC_HAVE_SIGNED_ZERO__
2365 +#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
2367 +++ b/libc/sysdeps/linux/avr32/bits/wordsize.h
2369 +#define __WORDSIZE 32
2371 +++ b/libc/sysdeps/linux/avr32/brk.c
2374 + * Copyright (C) 2004-2007 Atmel Corporation
2376 + * This file is subject to the terms and conditions of the GNU Lesser General
2377 + * Public License. See the file "COPYING.LIB" in the main directory of this
2378 + * archive for more details.
2381 +#include <unistd.h>
2382 +#include <sys/syscall.h>
2384 +libc_hidden_proto(brk)
2386 +void *__curbrk attribute_hidden = 0;
2388 +int brk (void *addr)
2392 + newbrk = (void *)INLINE_SYSCALL(brk, 1, addr);
2394 + __curbrk = newbrk;
2396 + if (newbrk < addr) {
2397 + __set_errno (ENOMEM);
2403 +libc_hidden_def(brk)
2405 +++ b/libc/sysdeps/linux/avr32/bsd-_setjmp.S
2408 + * Copyright (C) 2004-2007 Atmel Corporation
2410 + * This file is subject to the terms and conditions of the GNU Lesser General
2411 + * Public License. See the file "COPYING.LIB" in the main directory of this
2412 + * archive for more details.
2415 + /* This just does a tail-call to __sigsetjmp(env, 0) */
2417 + .type _setjmp,"function"
2421 + bral __GI___sigsetjmp
2422 + .size _setjmp, . - _setjmp
2424 +++ b/libc/sysdeps/linux/avr32/bsd-setjmp.S
2427 + * Copyright (C) 2004-2007 Atmel Corporation
2429 + * This file is subject to the terms and conditions of the GNU Lesser General
2430 + * Public License. See the file "COPYING.LIB" in the main directory of this
2431 + * archive for more details.
2434 + /* This just does a tail-call to __sigsetjmp(env, 1) */
2436 + .type setjmp,"function"
2440 + bral __GI___sigsetjmp
2441 + .size setjmp, . - setjmp
2443 +++ b/libc/sysdeps/linux/avr32/clone.c
2446 + * Copyright (C) 2004 Atmel Corporation
2448 + * This file is subject to the terms and conditions of the GNU Lesser General
2449 + * Public License. See the file "COPYING.LIB" in the main directory of this
2450 + * archive for more details.
2453 +#include <sys/syscall.h>
2454 +#include <unistd.h>
2457 + * I don't know if we can be absolutely certain that the fn and arg
2458 + * parameters are preserved when returning as the child. If the
2459 + * compiler stores them in registers (r0-r7), they should be.
2461 +int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg)
2463 + register int (*_fn)(void *arg) = fn;
2464 + register void *_arg = arg;
2467 + /* Sanity check the arguments */
2470 + goto syscall_error;
2472 + goto syscall_error;
2474 + err = INLINE_SYSCALL(clone, 2, flags, child_stack);
2476 + goto syscall_error;
2477 + else if (err != 0)
2483 + __set_errno (-err);
2487 +++ b/libc/sysdeps/linux/avr32/crt1.S
2490 + * Copyright (C) 2004-2007 Atmel Corporation
2492 + * This file is subject to the terms and conditions of the GNU Lesser General
2493 + * Public License. See the file "COPYING.LIB" in the main directory of this
2494 + * archive for more details.
2496 + * When we enter _start, the stack looks like this:
2497 + * argc argument counter
2498 + * argv[0] pointer to program name
2499 + * argv[1..argc-1] pointers to program args
2501 + * env[0..N] pointers to environment variables
2504 + * r12 contains a function pointer to be registered with `atexit'.
2505 + * This is how the dynamic linker arranges to have DT_FINI functions
2506 + * called for shared libraries that have been loaded before this
2509 + * We're going to call the following function:
2510 + * __uClibc_main(int (*main)(int, char **, char **), int argc,
2511 + * char **argv, void (*app_init)(void), void (*app_fini)(void),
2512 + * void (*rtld_fini)(void), void *stack_end)
2514 + * So we need to set up things as follows:
2515 + * r12 = address of main
2518 + * r9 = address of _init
2519 + * r8 = address of _fini
2520 + * sp[0] = whatever we got passed in r12
2523 +#include <features.h>
2527 + .type _start, @function
2529 + /* Clear the frame pointer and link register since this is the outermost frame. */
2533 + ld.w r11, sp++ /* argc */
2534 + mov r10, sp /* &argv[0] */
2536 + st.w --sp, r10 /* stack_end */
2537 + st.w --sp, r12 /* rtld_fini */
2547 + /* Ok, now run uClibc's main() -- should not return */
2548 + call __uClibc_main
2552 + .long .L_RGOT - _GLOBAL_OFFSET_TABLE_
2554 + lddpc r9, __init_addr /* app_init */
2555 + lddpc r8, __fini_addr /* app_fini */
2556 + lddpc r12, __main_addr /* main */
2558 + /* Ok, now run uClibc's main() -- should not return */
2559 + lddpc pc, ___uClibc_main_addr
2568 +___uClibc_main_addr:
2569 + .long __uClibc_main
2571 + .size _start, . - _start
2574 + * The LSB says we need this.
2576 + .section ".note.ABI-tag", "a"
2578 + .long 2f - 1f /* namesz */
2579 + .long 4f - 3f /* descsz */
2580 + .long 1 /* type */
2581 +1: .asciz "GNU" /* name */
2583 +3: .long 0 /* Linux executable */
2584 + .long 2,6,0 /* Earliest compatible kernel */
2587 +++ b/libc/sysdeps/linux/avr32/crti.S
2593 + .type _init, @function
2600 +2: .long 1b - _GLOBAL_OFFSET_TABLE_
2606 + .type _fini, @function
2613 +2: .long 1b - _GLOBAL_OFFSET_TABLE_
2616 +++ b/libc/sysdeps/linux/avr32/crtn.S
2622 + .type _init, @function
2624 + .size _init, . - _init
2629 + .type _fini, @function
2631 + .size _fini, . - _fini
2633 +++ b/libc/sysdeps/linux/avr32/mmap.c
2636 + * Copyright (C) 2004-2007 Atmel Corporation
2638 + * This file is subject to the terms and conditions of the GNU Lesser General
2639 + * Public License. See the file "COPYING.LIB" in the main directory of this
2640 + * archive for more details.
2644 +#include <unistd.h>
2645 +#include <sys/mman.h>
2646 +#include <sys/syscall.h>
2648 +libc_hidden_proto(mmap)
2650 +static _syscall6(__ptr_t, mmap2, __ptr_t, addr, size_t, len, int, prot,
2651 + int, flags, int, fd, __off_t, pgoff);
2653 +__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
2655 + unsigned long page_size = sysconf(_SC_PAGESIZE);
2656 + unsigned long pgoff;
2658 + if (offset & (page_size - 1)) {
2659 + __set_errno(EINVAL);
2660 + return MAP_FAILED;
2663 + pgoff = (unsigned long)offset >> (31 - __builtin_clz(page_size));
2665 + return mmap2(addr, len, prot, flags, fd, pgoff);
2667 +libc_hidden_def(mmap)
2669 +++ b/libc/sysdeps/linux/avr32/setjmp.S
2672 + * Copyright (C) 2004-2007 Atmel Corporation
2674 + * This file is subject to the terms and conditions of the GNU Lesser General
2675 + * Public License. See the file "COPYING.LIB" in the main directory of this
2676 + * archive for more details.
2680 +#include <bits/setjmp.h>
2684 + .global __sigsetjmp
2685 + .type __sigsetjmp,"function"
2690 + stm r12, r0,r1,r2,r3,r4,r5,r6,r7,r8,sp,lr
2693 + * Make a tail call to __sigjmp_save; it takes the same args
2694 + * and is hidden so we don't need to mess around with the GOT.
2696 + rjmp __sigjmp_save
2697 + .size __sigsetjmp, . - __sigsetjmp
2699 +libc_hidden_def(__sigsetjmp)
2701 +++ b/libc/sysdeps/linux/avr32/sigaction.c
2704 + * Copyright (C) 2004-2007 Atmel Corporation
2706 + * This file is subject to the terms and conditions of the GNU Lesser General
2707 + * Public License. See the file "COPYING.LIB" in the main directory of this
2708 + * archive for more details.
2711 +#include <signal.h>
2712 +#include <string.h>
2713 +#include <sys/syscall.h>
2714 +#include <bits/kernel_sigaction.h>
2716 +#define SA_RESTORER 0x04000000
2717 +extern void __default_rt_sa_restorer(void);
2719 +libc_hidden_proto(memcpy)
2722 + * If act is not NULL, change the action for sig to *act.
2723 + * If oact is not NULL, put the old action for sig in *oact.
2725 +int __libc_sigaction(int signum, const struct sigaction *act,
2726 + struct sigaction *oldact)
2728 + struct kernel_sigaction kact, koact;
2732 + kact.k_sa_handler = act->sa_handler;
2733 + memcpy(&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
2734 + kact.sa_flags = act->sa_flags;
2735 + if (kact.sa_flags & (SA_RESTORER | SA_ONSTACK))
2736 + kact.sa_restorer = act->sa_restorer;
2738 + kact.sa_restorer = __default_rt_sa_restorer;
2739 + kact.sa_flags |= SA_RESTORER;
2742 + result = __syscall_rt_sigaction(signum, act ? __ptrvalue(&kact) : NULL,
2743 + oldact ? __ptrvalue(&koact) : NULL,
2746 + if (oldact && result >= 0) {
2747 + oldact->sa_handler = koact.k_sa_handler;
2748 + memcpy(&oldact->sa_mask, &koact.sa_mask,
2749 + sizeof(oldact->sa_mask));
2750 + oldact->sa_flags = koact.sa_flags;
2751 + oldact->sa_restorer = koact.sa_restorer;
2757 +#ifndef LIBC_SIGACTION
2758 +libc_hidden_proto(sigaction)
2759 +weak_alias(__libc_sigaction, sigaction)
2760 +libc_hidden_weak(sigaction)
2763 +++ b/libc/sysdeps/linux/avr32/sigrestorer.S
2766 + * Copyright (C) 2004 Atmel Corporation
2768 + * This file is subject to the terms and conditions of the GNU Lesser General
2769 + * Public License. See the file "COPYING.LIB" in the main directory of this
2770 + * archive for more details.
2772 +#include <sys/syscall.h>
2774 + .global __default_rt_sa_restorer
2775 + .type __default_rt_sa_restorer,"function"
2777 +__default_rt_sa_restorer:
2778 + mov r8, __NR_rt_sigreturn
2781 +++ b/libc/sysdeps/linux/avr32/sys/elf.h
2783 +/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
2784 + This file is part of the GNU C Library.
2786 + The GNU C Library is free software; you can redistribute it and/or
2787 + modify it under the terms of the GNU Lesser General Public
2788 + License as published by the Free Software Foundation; either
2789 + version 2.1 of the License, or (at your option) any later version.
2791 + The GNU C Library is distributed in the hope that it will be useful,
2792 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2793 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2794 + Lesser General Public License for more details.
2796 + You should have received a copy of the GNU Lesser General Public
2797 + License along with the GNU C Library; if not, write to the Free
2798 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2799 + 02111-1307 USA. */
2802 +#define _SYS_ELF_H 1
2804 +#warning "This header is obsolete; use <sys/procfs.h> instead."
2806 +#include <sys/procfs.h>
2808 +#endif /* sys/elf.h */
2810 +++ b/libc/sysdeps/linux/avr32/sys/procfs.h
2812 +/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
2813 + This file is part of the GNU C Library.
2815 + The GNU C Library is free software; you can redistribute it and/or
2816 + modify it under the terms of the GNU Lesser General Public
2817 + License as published by the Free Software Foundation; either
2818 + version 2.1 of the License, or (at your option) any later version.
2820 + The GNU C Library is distributed in the hope that it will be useful,
2821 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2822 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2823 + Lesser General Public License for more details.
2825 + You should have received a copy of the GNU Lesser General Public
2826 + License along with the GNU C Library; if not, write to the Free
2827 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2828 + 02111-1307 USA. */
2830 +#ifndef _SYS_PROCFS_H
2831 +#define _SYS_PROCFS_H 1
2833 +/* This is somewhat modelled after the file of the same name on SVR4
2834 + systems. It provides a definition of the core file format for ELF
2835 + used on Linux. It doesn't have anything to do with the /proc file
2836 + system, even though Linux has one.
2838 + Anyway, the whole purpose of this file is for GDB and GDB only.
2839 + Don't read too much into it. Don't use it for anything other than
2840 + GDB unless you know what you are doing. */
2842 +#include <features.h>
2843 +#include <sys/time.h>
2844 +#include <sys/types.h>
2845 +#include <sys/user.h>
2849 +/* Type for a general-purpose register. */
2850 +typedef unsigned long elf_greg_t;
2852 +/* And the whole bunch of them. We could have used `struct
2853 + user_regs' directly in the typedef, but tradition says that
2854 + the register set is an array, which does have some peculiar
2855 + semantics, so leave it that way. */
2856 +#define ELF_NGREG (sizeof (struct user_regs) / sizeof(elf_greg_t))
2857 +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
2859 +/* Register set for the floating-point registers. */
2860 +typedef struct user_fpregs elf_fpregset_t;
2865 + int si_signo; /* Signal number. */
2866 + int si_code; /* Extra code. */
2867 + int si_errno; /* Errno. */
2870 +/* Definitions to generate Intel SVR4-like core files. These mostly
2871 + have the same names as the SVR4 types with "elf_" tacked on the
2872 + front to prevent clashes with Linux definitions, and the typedef
2873 + forms have been avoided. This is mostly like the SVR4 structure,
2874 + but more Linuxy, with things that Linux does not support and which
2875 + GDB doesn't really use excluded. */
2877 +struct elf_prstatus
2879 + struct elf_siginfo pr_info; /* Info associated with signal. */
2880 + short int pr_cursig; /* Current signal. */
2881 + unsigned long int pr_sigpend; /* Set of pending signals. */
2882 + unsigned long int pr_sighold; /* Set of held signals. */
2887 + struct timeval pr_utime; /* User time. */
2888 + struct timeval pr_stime; /* System time. */
2889 + struct timeval pr_cutime; /* Cumulative user time. */
2890 + struct timeval pr_cstime; /* Cumulative system time. */
2891 + elf_gregset_t pr_reg; /* GP registers. */
2892 + int pr_fpvalid; /* True if math copro being used. */
2896 +#define ELF_PRARGSZ (80) /* Number of chars for args. */
2898 +struct elf_prpsinfo
2900 + char pr_state; /* Numeric process state. */
2901 + char pr_sname; /* Char for pr_state. */
2902 + char pr_zomb; /* Zombie. */
2903 + char pr_nice; /* Nice val. */
2904 + unsigned long int pr_flag; /* Flags. */
2905 + unsigned short int pr_uid;
2906 + unsigned short int pr_gid;
2907 + int pr_pid, pr_ppid, pr_pgrp, pr_sid;
2908 + /* Lots missing */
2909 + char pr_fname[16]; /* Filename of executable. */
2910 + char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
2913 +/* The rest of this file provides the types for emulation of the
2914 + Solaris <proc_service.h> interfaces that should be implemented by
2915 + users of libthread_db. */
2918 +typedef void *psaddr_t;
2920 +/* Register sets. Linux has different names. */
2921 +typedef elf_gregset_t prgregset_t;
2922 +typedef elf_fpregset_t prfpregset_t;
2924 +/* We don't have any differences between processes and threads,
2925 + therefore have only one PID type. */
2926 +typedef __pid_t lwpid_t;
2928 +/* Process status and info. In the end we do provide typedefs for them. */
2929 +typedef struct elf_prstatus prstatus_t;
2930 +typedef struct elf_prpsinfo prpsinfo_t;
2934 +#endif /* sys/procfs.h */
2936 +++ b/libc/sysdeps/linux/avr32/sys/ucontext.h
2938 +/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
2939 + This file is part of the GNU C Library.
2941 + The GNU C Library is free software; you can redistribute it and/or
2942 + modify it under the terms of the GNU Lesser General Public
2943 + License as published by the Free Software Foundation; either
2944 + version 2.1 of the License, or (at your option) any later version.
2946 + The GNU C Library is distributed in the hope that it will be useful,
2947 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2948 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2949 + Lesser General Public License for more details.
2951 + You should have received a copy of the GNU Lesser General Public
2952 + License along with the GNU C Library; if not, write to the Free
2953 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2954 + 02111-1307 USA. */
2956 +/* Linux/AVR32 ABI compliant context switching support. */
2958 +#ifndef _SYS_UCONTEXT_H
2959 +#define _SYS_UCONTEXT_H 1
2961 +#include <features.h>
2962 +#include <signal.h>
2963 +#include <sys/procfs.h>
2964 +#include <bits/sigcontext.h>
2966 +typedef int greg_t;
2968 +/* Number of general registers. */
2971 +/* Container for all general registers. */
2972 +typedef elf_gregset_t gregset_t;
2974 +/* Number of each register is the `gregset_t' array. */
3011 +/* Structure to describe FPU registers. */
3012 +typedef elf_fpregset_t fpregset_t;
3014 +/* Context to describe whole processor state. */
3015 +typedef struct sigcontext mcontext_t;
3017 +/* Userlevel context. */
3018 +typedef struct ucontext
3020 + unsigned long uc_flags;
3021 + struct ucontext *uc_link;
3023 + mcontext_t uc_mcontext;
3024 + sigset_t uc_sigmask; /* mask last for extensibility */
3027 +#endif /* sys/ucontext.h */
3029 +++ b/libc/sysdeps/linux/avr32/sys/user.h
3031 +#ifndef _SYS_USER_H
3032 +#define _SYS_USER_H
3045 + unsigned long r12;
3046 + unsigned long r11;
3047 + unsigned long r10;
3058 + unsigned long r12_orig;
3063 + struct user_regs regs; /* general registers */
3064 + size_t u_tsize; /* text size (pages) */
3065 + size_t u_dsize; /* data size (pages) */
3066 + size_t u_ssize; /* stack size (pages) */
3067 + unsigned long start_code; /* text starting address */
3068 + unsigned long start_data; /* data starting address */
3069 + unsigned long start_stack; /* stack starting address */
3070 + long int signal; /* signal causing core dump */
3071 + struct user_regs * u_ar0; /* help gdb find registers */
3072 + unsigned long magic; /* identifies a core file */
3073 + char u_comm[32]; /* user command name */
3076 +#endif /* _SYS_USER_H */
3078 +++ b/libc/sysdeps/linux/avr32/syscall.S
3081 + * Copyright (C) 2004-2007 Atmel Corporation
3083 + * This file is subject to the terms and conditions of the GNU Lesser General
3084 + * Public License. See the file "COPYING.LIB" in the main directory of this
3085 + * archive for more details.
3087 +#include <features.h>
3092 + * long int syscall(long int sysno, ...)
3095 + .type syscall, @function
3098 + stm --sp, r3,r5,r6,lr
3101 + ldm lr, r3,r5,r9-r12
3110 +# ifdef __UCLIBC_HAS_THREADS__
3112 + mcall r6[__errno_location@got]
3115 + ld.w r3, r6[errno@got]
3120 +# ifdef __UCLIBC_HAS_THREADS__
3122 + mcall .Lerrno_location
3133 + ldm sp++, r3,r5,r6,pc
3138 + .long .Lgotcalc - _GLOBAL_OFFSET_TABLE_
3140 +# ifdef __UCLIBC_HAS_THREADS__
3142 + .long __errno_location
3150 + .size syscall, . - syscall
3152 +++ b/libc/sysdeps/linux/avr32/vfork.S
3155 + * Copyright (C) 2005 Atmel Corporation
3157 + * This file is subject to the terms and conditions of the GNU Lesser General
3158 + * Public License. See the file "COPYING.LIB" in the main directory of this
3159 + * archive for more details.
3163 + * Clone the process without copying the address space. The
3164 + * calling process is suspended until the child either exits
3165 + * or calls execve.
3167 + * This all means that we cannot rely on the stack to store
3168 + * away registers, since they will be overwritten by the child
3169 + * as soon as it makes another function call (e.g. execve()).
3170 + * Fortunately, the Linux kernel preserves LR across system calls.
3173 +#include <features.h>
3174 +#include <sys/syscall.h>
3177 + .type __vfork,@function
3180 + mov r8, __NR_vfork
3185 + /* vfork failed, so we may use the stack freely */
3192 + mcall r6[__errno_location@got]
3195 + mcall .L__errno_location
3198 + popm r4-r7,pc,r12=-1
3203 + .long .L_RGOT - _GLOBAL_OFFSET_TABLE_
3205 +.L__errno_location:
3206 + .long __errno_location
3208 + .size __vfork, . - __vfork
3210 +weak_alias(__vfork,vfork)
3211 +libc_hidden_weak(vfork)
3213 +++ b/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
3215 +/* Machine-dependent pthreads configuration and inline functions.
3217 + * Copyright (C) 2005-2007 Atmel Corporation
3219 + * This file is subject to the terms and conditions of the GNU Lesser General
3220 + * Public License. See the file "COPYING.LIB" in the main directory of this
3221 + * archive for more details.
3223 +#ifndef _PT_MACHINE_H
3224 +#define _PT_MACHINE_H 1
3226 +#include <features.h>
3229 +_test_and_set (int *p, int v)
3233 + __asm__ __volatile__(
3234 + "/* Inline test and set */\n"
3235 + " xchg %[old], %[mem], %[new]"
3236 + : [old] "=&r"(result)
3237 + : [mem] "r"(p), [new] "r"(v)
3244 +# define PT_EI extern inline
3247 +extern long int testandset (int *spinlock);
3248 +extern int __compare_and_swap (long int *p, long int oldval, long int newval);
3250 +/* Spinlock implementation; required. */
3252 +testandset (int *spinlock)
3254 + return _test_and_set(spinlock, 1);
3258 +/* Get some notion of the current stack. Need not be exactly the top
3259 + of the stack, just something somewhere in the current frame. */
3260 +#define CURRENT_STACK_FRAME stack_pointer
3261 +register char * stack_pointer __asm__ ("sp");
3263 +/* Compare-and-swap for semaphores. */
3265 +#define HAS_COMPARE_AND_SWAP
3267 +__compare_and_swap(long int *p, long int oldval, long int newval)
3271 + __asm__ __volatile__(
3272 + "/* Inline compare and swap */\n"
3274 + " ld.w %[result], %[mem]\n"
3275 + " eor %[result], %[old]\n"
3277 + " stcond %[mem], %[new]\n"
3280 + : [result] "=&r"(result), [mem] "=m"(*p)
3281 + : "m"(*p), [new] "r"(newval), [old] "r"(oldval)
3282 + : "cc", "memory");
3284 + return result == 0;
3287 +#endif /* pt-machine.h */
3289 +++ b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
3291 +/* Machine-dependent pthreads configuration and inline functions.
3293 + * Copyright (C) 2005-2007 Atmel Corporation
3295 + * This file is subject to the terms and conditions of the GNU Lesser General
3296 + * Public License. See the file "COPYING.LIB" in the main directory of this
3297 + * archive for more details.
3299 +#ifndef _PT_MACHINE_H
3300 +#define _PT_MACHINE_H 1
3302 +#include <features.h>
3305 +_test_and_set (int *p, int v) __THROW
3309 + __asm__ __volatile__(
3310 + "/* Inline test and set */\n"
3311 + " xchg %[old], %[mem], %[new]"
3312 + : [old] "=&r"(result)
3313 + : [mem] "r"(p), [new] "r"(v)
3320 +# define PT_EI extern inline
3323 +extern long int testandset (int *spinlock);
3324 +extern int __compare_and_swap (long int *p, long int oldval, long int newval);
3326 +/* Spinlock implementation; required. */
3328 +testandset (int *spinlock)
3330 + return _test_and_set(spinlock, 1);
3334 +/* Get some notion of the current stack. Need not be exactly the top
3335 + of the stack, just something somewhere in the current frame. */
3336 +#define CURRENT_STACK_FRAME stack_pointer
3337 +register char * stack_pointer __asm__ ("sp");
3339 +/* Compare-and-swap for semaphores. */
3341 +#define HAS_COMPARE_AND_SWAP
3343 +__compare_and_swap(long int *p, long int oldval, long int newval)
3347 + __asm__ __volatile__(
3348 + "/* Inline compare and swap */\n"
3350 + " ld.w %[result], %[mem]\n"
3351 + " eor %[result], %[old]\n"
3353 + " stcond %[mem], %[new]\n"
3356 + : [result] "=&r"(result), [mem] "=m"(*p)
3357 + : "m"(*p), [new] "r"(newval), [old] "r"(oldval)
3358 + : "cc", "memory");
3360 + return result == 0;
3363 +#endif /* pt-machine.h */
3367 #define ELFCLASSM ELFCLASS32
3370 +#if defined(__avr32__)
3371 +#define MATCH_MACHINE(x) (x == EM_AVR32)
3372 +#define ELFCLASSM ELFCLASS32
3375 #if defined(__s390__)
3376 #define MATCH_MACHINE(x) (x == EM_S390)
3377 #define ELFCLASSM ELFCLASS32