OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/gnu-dev
    from Rev 704 to Rev 705
    Reverse comparison

Rev 704 → Rev 705

/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-next-encode-assist-impl.h
0,0 → 1,654
#ifndef _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_IMPL_H_
#define _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_IMPL_H_
 
#ifdef __NEXT_RUNTIME__
 
/* Determine which API to use. */
#include "next-abi.h"
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
#include <objc/runtime.h>
#else
#include <objc/objc-runtime.h>
#endif
 
/* ---- */
 
#undef MAX
#undef MIN
#undef ROUND
 
#ifdef __cplusplus
# define MAX(X, Y) ((X > Y) ? X : Y)
# define MIN(X, Y) ((X < Y) ? X : Y)
# define ROUND(V, A) (A * ((V + A - 1) / A))
#else
# define MAX(X, Y) \
({ typeof (X) __x = (X), __y = (Y); \
(__x > __y ? __x : __y); })
# define MIN(X, Y) \
({ typeof (X) __x = (X), __y = (Y); \
(__x < __y ? __x : __y); })
# define ROUND(V, A) \
({ typeof (V) __v = (V); typeof (A) __a = (A); \
__a * ((__v+__a - 1)/__a); })
#endif
 
#define BITS_PER_UNIT __CHAR_BIT__
typedef struct{ char a; } __small_struct;
#define STRUCTURE_SIZE_BOUNDARY (BITS_PER_UNIT * sizeof (__small_struct))
 
/*
return the size of an object specified by type
*/
 
int
objc_sizeof_type (const char *type)
{
/* Skip the variable name if any */
if (*type == '"')
{
for (type++; *type++ != '"';)
/* do nothing */;
}
 
switch (*type) {
case _C_ID:
return sizeof (id);
break;
 
case _C_CLASS:
return sizeof (Class);
break;
 
case _C_SEL:
return sizeof (SEL);
break;
 
case _C_CHR:
return sizeof (char);
break;
 
case _C_UCHR:
return sizeof (unsigned char);
break;
 
case _C_SHT:
return sizeof (short);
break;
 
case _C_USHT:
return sizeof (unsigned short);
break;
 
case _C_INT:
return sizeof (int);
break;
 
case _C_UINT:
return sizeof (unsigned int);
break;
 
case _C_LNG:
return sizeof (long);
break;
 
case _C_ULNG:
return sizeof (unsigned long);
break;
 
case _C_LNG_LNG:
return sizeof (long long);
break;
 
case _C_ULNG_LNG:
return sizeof (unsigned long long);
break;
 
case _C_FLT:
return sizeof (float);
break;
 
case _C_DBL:
return sizeof (double);
break;
 
case _C_PTR:
case _C_ATOM:
case _C_CHARPTR:
return sizeof (char *);
break;
 
case _C_ARY_B:
{
int len = atoi (type + 1);
while (isdigit ((unsigned char)*++type))
;
return len * objc_aligned_size (type);
}
break;
 
case _C_BFLD:
{
/* The NeXT encoding of bitfields is _still_: b 'size' */
int size = atoi (type + 1);
/* Return an upper bound on byte size */
return (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
}
 
case _C_STRUCT_B:
{
struct objc_struct_layout layout;
unsigned int size;
 
objc_layout_structure (type, &layout);
while (objc_layout_structure_next_member (&layout))
/* do nothing */ ;
objc_layout_finish_structure (&layout, &size, NULL);
 
return size;
}
 
case _C_UNION_B:
{
int max_size = 0;
while (*type != _C_UNION_E && *type++ != '=')
/* do nothing */;
while (*type != _C_UNION_E)
{
/* Skip the variable name if any */
if (*type == '"')
{
for (type++; *type++ != '"';)
/* do nothing */;
}
max_size = MAX (max_size, objc_sizeof_type (type));
type = objc_skip_typespec (type);
}
return max_size;
}
}
return 0; /* error */
}
 
 
/*
Return the alignment of an object specified by type
*/
 
int
objc_alignof_type (const char *type)
{
/* Skip the variable name if any */
if (*type == '"')
{
for (type++; *type++ != '"';)
/* do nothing */;
}
switch (*type) {
case _C_ID:
return __alignof__ (id);
break;
 
case _C_CLASS:
return __alignof__ (Class);
break;
 
case _C_SEL:
return __alignof__ (SEL);
break;
 
case _C_CHR:
return __alignof__ (char);
break;
 
case _C_UCHR:
return __alignof__ (unsigned char);
break;
 
case _C_SHT:
return __alignof__ (short);
break;
 
case _C_USHT:
return __alignof__ (unsigned short);
break;
 
case _C_INT:
case _C_BFLD: /* This is for the NeXT only */
return __alignof__ (int);
break;
 
case _C_UINT:
return __alignof__ (unsigned int);
break;
 
case _C_LNG:
return __alignof__ (long);
break;
 
case _C_ULNG:
return __alignof__ (unsigned long);
break;
 
case _C_LNG_LNG:
return __alignof__ (long long);
break;
 
case _C_ULNG_LNG:
return __alignof__ (unsigned long long);
break;
 
case _C_FLT:
return __alignof__ (float);
break;
 
case _C_DBL:
return __alignof__ (double);
break;
 
case _C_PTR:
case _C_ATOM:
case _C_CHARPTR:
return __alignof__ (char *);
break;
 
case _C_ARY_B:
while (isdigit ((unsigned char)*++type))
/* do nothing */;
return objc_alignof_type (type);
 
case _C_STRUCT_B:
{
struct objc_struct_layout layout;
unsigned int align;
 
objc_layout_structure (type, &layout);
while (objc_layout_structure_next_member (&layout))
/* do nothing */;
objc_layout_finish_structure (&layout, NULL, &align);
 
return align;
}
 
case _C_UNION_B:
{
int maxalign = 0;
while (*type != _C_UNION_E && *type++ != '=')
/* do nothing */;
while (*type != _C_UNION_E)
{
/* Skip the variable name if any */
if (*type == '"')
{
for (type++; *type++ != '"';)
/* do nothing */;
}
maxalign = MAX (maxalign, objc_alignof_type (type));
type = objc_skip_typespec (type);
}
return maxalign;
}
}
return 0; /* error */
}
 
/*
The aligned size if the size rounded up to the nearest alignment.
*/
 
int
objc_aligned_size (const char *type)
{
int size, align;
 
/* Skip the variable name */
if (*type == '"')
{
for (type++; *type++ != '"';)
/* do nothing */;
}
 
size = objc_sizeof_type (type);
align = objc_alignof_type (type);
 
return ROUND (size, align);
}
 
/*
The size rounded up to the nearest integral of the wordsize, taken
to be the size of a void *.
*/
 
int
objc_promoted_size (const char *type)
{
int size, wordsize;
 
/* Skip the variable name */
if (*type == '"')
{
for (type++; *type++ != '"';)
/* do nothing */;
}
 
size = objc_sizeof_type (type);
wordsize = sizeof (void *);
 
return ROUND (size, wordsize);
}
 
/*
Skip type qualifiers. These may eventually precede typespecs
occurring in method prototype encodings.
*/
 
const char *
objc_skip_type_qualifiers (const char *type)
{
while (*type == _C_CONST
|| *type == _C_IN
|| *type == _C_INOUT
|| *type == _C_OUT
|| *type == _C_BYCOPY
|| *type == _C_BYREF
|| *type == _C_ONEWAY
|| *type == _C_GCINVISIBLE)
{
type += 1;
}
return type;
}
 
/*
Skip one typespec element. If the typespec is prepended by type
qualifiers, these are skipped as well.
*/
 
const char *
objc_skip_typespec (const char *type)
{
/* Skip the variable name if any */
if (*type == '"')
{
for (type++; *type++ != '"';)
/* do nothing */;
}
 
type = objc_skip_type_qualifiers (type);
 
switch (*type) {
 
case _C_ID:
/* An id may be annotated by the actual type if it is known
with the @"ClassName" syntax */
 
if (*++type != '"')
return type;
else
{
while (*++type != '"')
/* do nothing */;
return type + 1;
}
 
/* The following are one character type codes */
case _C_CLASS:
case _C_SEL:
case _C_CHR:
case _C_UCHR:
case _C_CHARPTR:
case _C_ATOM:
case _C_SHT:
case _C_USHT:
case _C_INT:
case _C_UINT:
case _C_LNG:
case _C_ULNG:
case _C_LNG_LNG:
case _C_ULNG_LNG:
case _C_FLT:
case _C_DBL:
case _C_VOID:
case _C_UNDEF:
return ++type;
break;
 
case _C_ARY_B:
/* skip digits, typespec and closing ']' */
 
while (isdigit ((unsigned char)*++type))
;
type = objc_skip_typespec (type);
if (*type == _C_ARY_E)
return ++type;
else
break; /* error */
 
case _C_BFLD:
/* The NeXT encoding for bitfields is _still_: b 'size' */
while (isdigit ((unsigned char)*++type))
; /* skip type and size */
return type;
 
case _C_STRUCT_B:
/* skip name, and elements until closing '}' */
 
while (*type != _C_STRUCT_E && *type++ != '=')
;
while (*type != _C_STRUCT_E)
{
type = objc_skip_typespec (type);
}
return ++type;
 
case _C_UNION_B:
/* skip name, and elements until closing ')' */
 
while (*type != _C_UNION_E && *type++ != '=')
;
while (*type != _C_UNION_E)
{
type = objc_skip_typespec (type);
}
return ++type;
 
case _C_PTR:
/* Just skip the following typespec */
 
return objc_skip_typespec (++type);
}
return 0; /* error */
}
 
/*
Skip an offset as part of a method encoding. This is prepended by a
'+' if the argument is passed in registers.
*/
const char *
objc_skip_offset (const char *type)
{
if (*type == '+')
type++;
while (isdigit ((unsigned char) *++type))
;
return type;
}
 
/*
Skip an argument specification of a method encoding.
*/
const char *
objc_skip_argspec (const char *type)
{
type = objc_skip_typespec (type);
type = objc_skip_offset (type);
return type;
}
 
unsigned
objc_get_type_qualifiers (const char *type)
{
unsigned res = 0;
BOOL flag = YES;
 
while (flag)
switch (*type++)
{
case _C_CONST: res |= _F_CONST; break;
case _C_IN: res |= _F_IN; break;
case _C_INOUT: res |= _F_INOUT; break;
case _C_OUT: res |= _F_OUT; break;
case _C_BYCOPY: res |= _F_BYCOPY; break;
case _C_BYREF: res |= _F_BYREF; break;
case _C_ONEWAY: res |= _F_ONEWAY; break;
case _C_GCINVISIBLE: res |= _F_GCINVISIBLE; break;
default: flag = NO;
}
 
return res;
}
 
 
/* The following three functions can be used to determine how a
structure is laid out by the compiler. For example:
 
struct objc_struct_layout layout;
int i;
 
objc_layout_structure (type, &layout);
while (objc_layout_structure_next_member (&layout))
{
int position, align;
const char *type;
 
objc_layout_structure_get_info (&layout, &position, &align, &type);
printf ("element %d has offset %d, alignment %d\n",
i++, position, align);
}
 
These functions are used by objc_sizeof_type and objc_alignof_type
functions to compute the size and alignment of structures. The
previous method of computing the size and alignment of a structure
was not working on some architectures, particulary on AIX, and in
the presence of bitfields inside the structure. */
void
objc_layout_structure (const char *type,
struct objc_struct_layout *layout)
{
const char *ntype;
 
layout->original_type = ++type;
 
/* Skip "<name>=" if any. Avoid embedded structures and unions. */
ntype = type;
while (*ntype != _C_STRUCT_E && *ntype != _C_STRUCT_B && *ntype != _C_UNION_B
&& *ntype++ != '=')
/* do nothing */;
 
/* If there's a "<name>=", ntype - 1 points to '='; skip the name */
if (*(ntype - 1) == '=')
type = ntype;
 
layout->type = type;
layout->prev_type = NULL;
layout->record_size = 0;
layout->record_align = MAX (BITS_PER_UNIT, STRUCTURE_SIZE_BOUNDARY);
}
 
BOOL
objc_layout_structure_next_member (struct objc_struct_layout *layout)
{
register int desired_align = 0;
 
/* The current type without the type qualifiers */
const char *type;
 
/* Add the size of the previous field to the size of the record. */
if (layout->prev_type)
{
type = objc_skip_type_qualifiers (layout->prev_type);
 
if (*type != _C_BFLD)
layout->record_size += objc_sizeof_type (type) * BITS_PER_UNIT;
else
layout->record_size += atoi (++type);
}
 
if (*layout->type == _C_STRUCT_E)
return NO;
 
/* Skip the variable name if any */
if (*layout->type == '"')
{
for (layout->type++; *layout->type++ != '"';)
/* do nothing */;
}
 
type = objc_skip_type_qualifiers (layout->type);
 
desired_align = objc_alignof_type (type) * BITS_PER_UNIT;
 
/* Record must have at least as much alignment as any field.
Otherwise, the alignment of the field within the record
is meaningless. */
layout->record_align = MAX (layout->record_align, desired_align);
 
if (*type == _C_BFLD)
{
int bfld_size = atoi (++type);
int int_align = __alignof__ (int) * BITS_PER_UNIT;
/* If this bitfield would traverse a word alignment boundary, push it out
to that boundary instead. */
if (layout->record_size % int_align
&& (layout->record_size / int_align
< (layout->record_size + bfld_size - 1) / int_align))
layout->record_size = ROUND (layout->record_size, int_align);
}
else if (layout->record_size % desired_align != 0)
{
/* We need to skip space before this field.
Bump the cumulative size to multiple of field alignment. */
layout->record_size = ROUND (layout->record_size, desired_align);
}
 
/* Jump to the next field in record. */
 
layout->prev_type = layout->type;
layout->type = objc_skip_typespec (layout->type); /* skip component */
 
return YES;
}
 
 
void objc_layout_finish_structure (struct objc_struct_layout *layout,
unsigned int *size,
unsigned int *align)
{
if (layout->type && *layout->type == _C_STRUCT_E)
{
/* Round the size up to be a multiple of the required alignment */
layout->record_size = ROUND (layout->record_size, layout->record_align);
layout->type = NULL;
}
if (size)
*size = layout->record_size / BITS_PER_UNIT;
if (align)
*align = layout->record_align / BITS_PER_UNIT;
}
 
 
void objc_layout_structure_get_info (struct objc_struct_layout *layout,
unsigned int *offset,
unsigned int *align,
const char **type)
{
if (offset)
*offset = layout->record_size / BITS_PER_UNIT;
if (align)
*align = layout->record_align / BITS_PER_UNIT;
if (type)
*type = layout->prev_type;
}
 
#endif /* __NEXT_RUNTIME__ */
#endif /* _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_IMPL_H_ */
/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-next-encode-assist.h
0,0 → 1,74
#ifndef _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_H_
#define _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_H_
 
#ifdef __NEXT_RUNTIME__
 
#include "next-abi.h"
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
#include <objc/runtime.h>
#else
#include <objc/objc-runtime.h>
 
/* Missing from old NeXT objc headers... */
#define _C_LNG_LNG 'q'
#define _C_ULNG_LNG 'Q'
#define _C_ATOM '%'
#define _C_BOOL 'B'
 
#endif
 
/* The NeXT headers do not define NULL. */
#ifndef NULL
#define NULL 0
#endif
 
#define _C_CONST 'r'
#define _C_IN 'n'
#define _C_INOUT 'N'
#define _C_OUT 'o'
#define _C_BYCOPY 'O'
#define _C_BYREF 'R'
#define _C_ONEWAY 'V'
#define _C_GCINVISIBLE '!'
#define _F_CONST 0x01
#define _F_IN 0x01
#define _F_OUT 0x02
#define _F_INOUT 0x03
#define _F_BYCOPY 0x04
#define _F_BYREF 0x08
#define _F_ONEWAY 0x10
#define _F_GCINVISIBLE 0x20
 
/* The NeXT runtimes do not include these functions (at least not through
any public API). They are required for the objc/execute/bf-* and bycopy-3. */
 
struct objc_struct_layout
{
const char *original_type;
const char *type;
const char *prev_type;
unsigned int record_size;
unsigned int record_align;
};
 
void objc_layout_structure_get_info (struct objc_struct_layout *,unsigned int *,
unsigned int *, const char **);
void objc_layout_structure (const char *, struct objc_struct_layout *);
BOOL objc_layout_structure_next_member (struct objc_struct_layout *);
void objc_layout_finish_structure (struct objc_struct_layout *, unsigned int *,
unsigned int *);
 
int objc_sizeof_type (const char *);
int objc_alignof_type (const char *);
int objc_aligned_size (const char *);
int objc_promoted_size (const char *);
 
unsigned objc_get_type_qualifiers (const char *);
const char *objc_skip_type_qualifiers (const char *);
const char *objc_skip_typespec (const char *);
const char *objc_skip_offset (const char *);
const char *objc_skip_argspec (const char *);
 
#endif /* __NEXT_RUNTIME__ */
#endif /* _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_H_ */
/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/TestsuiteObject.h
0,0 → 1,47
/* Very simple root class for writing testcases.
Copyright (C) 2011 Free Software Foundation, Inc.
Contributed by Nicola Pero
 
This file is part of GCC.
 
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
 
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
 
#ifndef _TESTSUITE_OBJECT_H_
#define _TESTSUITE_OBJECT_H_
 
/* We use this root class instead of Object to keep the tests
independent of the runtime being used. Keep it simple. */
 
@interface TestsuiteObject
{
Class isa;
}
/* Required by the NeXT runtime. Does nothing. */
+ (id) initialize;
 
/* Creating instances. */
+ (id) new;
+ (id) alloc;
- (id) init;
- (id) free;
 
/* Auxiliary methods. */
+ (Class) class;
+ (Class) superclass;
+ (const char *)name;
- (const char *)name;
@end
 
#endif /* _TESTSUITE_OBJECT_H_ */
/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.h
0,0 → 1,61
/* A small NSConstantString implementation for use with the NeXT runtime.
Copyright (C) 2011 Free Software Foundation, Inc.
Contributed by Iain Sandoe <iains@gcc.gnu.org>
 
This file is part of GCC.
 
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
 
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
 
#ifdef __NEXT_RUNTIME__
 
#include "nsconstantstring-class.h"
#include <string.h>
 
/* On full-fledged Mac OS X systems, NSConstantString is provided
as part of the Foundation framework. However, on bare Darwin systems,
Foundation is not included, and hence there is no NSConstantString
implementation to link against.
 
This code is derived from the GNU runtime's NXConstantString implementation.
*/
 
@implementation NSConstantString
/* NeXT requires this or forward: */
+initialize { return self; }
 
-(const char *) cString
{
return (c_string);
}
 
-(unsigned int) length
{
return (len);
}
@end
 
TNS_STRING_REF_T _NSConstantStringClassReference;
 
/* The NSConstantString metaclass will need to be initialized before we can
send messages to strings. */
 
void objc_constant_string_init (void) __attribute__((constructor));
void objc_constant_string_init (void) {
memcpy (&_NSConstantStringClassReference,
objc_getClass ("NSConstantString"),
sizeof (_NSConstantStringClassReference));
}
#endif
/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-types.h
0,0 → 1,62
/* Define test-suite types to minimize conditional test-case source.
Copyright (C) 2011 Free Software Foundation, Inc.
Contributed by Iain Sandoe
 
This file is part of GCC.
 
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
 
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
 
#ifndef _OBJC_TEST_SUITE_TYPES_H_
#define _OBJC_TEST_SUITE_TYPES_H_
 
#ifndef __NEXT_RUNTIME__
 
/* dummy const string class ref. */
typedef void * TNS_STRING_REF_T;
 
#else /* NeXT */
 
#include "next-abi.h"
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
#include <objc/runtime.h>
#else
#include <objc/objc-runtime.h>
#endif
 
/* Force a definition of nil that is compatible with GNU runtime. */
#undef nil
#define nil ((id)0)
 
#ifndef NULL
#define NULL 0
#endif
 
/* Where there are equivalent interfaces between APIs we substitute
a macro or typedef. */
 
#ifdef __OBJC2__
/* Const String Class ref. */
typedef Class TNS_STRING_REF_T;
#else
/* Const String Class ref. */
/* We need objc_class - but we don't need endless reminders that it's deprecated. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
typedef struct objc_class TNS_STRING_REF_T;
#pragma GCC diagnostic pop
#endif
 
#endif /*__NEXT_RUNTIME__ */
#endif /* _OBJC_TEST_SUITE_TYPES_H_ */
/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/runtime.h
0,0 → 1,116
/* Wrapper around <objc/runtime.h>
Copyright (C) 2011 Free Software Foundation, Inc.
Contributed by Nicola Pero
 
This file is part of GCC.
 
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
 
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
 
#ifndef _TESTSUITE_RUNTIME_H_
#define _TESTSUITE_RUNTIME_H_
 
/* Include this file where you'd normally include <objc/runtime.h>.
 
Older versions of the NeXT runtime do not have <objc/runtime.h> and
you need to include <objc/objc-runtime.h> instead. This file takes
care of figuring out if that's the case. */
 
#ifndef __NEXT_RUNTIME__
 
/*
GNU Objective-C runtime (libobjc).
*/
# include <objc/runtime.h>
 
#else
 
/*
NeXT Objective-C runtime.
*/
 
/* Include next-abi.h to determine which version of the runtime we are
dealing with. TODO: If this is the only place including it, maybe
it could be copied here ? */
# include "next-abi.h"
 
# ifdef NEXT_OBJC_USE_NEW_INTERFACE
 
/* New NeXT runtime, with an API that should be basically identical to
the GNU Objective-C one. */
# include <objc/runtime.h>
 
# else
 
/* Old NeXT runtime, with an API similar, but not identical to the new
one. To start with, different headers need to be included. */
# include <objc/objc-class.h>
# include <objc/objc-runtime.h>
 
/* Not all functions are available in the old NeXT runtime. A few
that we need are not, and here we provide an implementation on top
of the old NeXT API. */
 
# define class_isMetaClass(C) (CLS_GETINFO((struct objc_class *)C, CLS_META)? YES: NO)
# define class_getName(C) object_getClassName(C)
# define class_getSuperclass(C) (((struct objc_class *)C)->super_class)
# define method_getImplementation(M) (((Method)M)->method_imp)
# define method_getTypeEncoding(M) (((Method)M)->method_types)
# define object_getClass(O) (*(struct objc_class **)O)
 
#include <objc/Protocol.h>
BOOL class_conformsToProtocol (Class class_, Protocol *protocol)
{
struct objc_protocol_list *p;
int i;
for (p = class_->protocols; p; p = p->next)
for (i = 0; i < p->count; i++)
if ([p->list[i] conformsTo: protocol])
return YES;
return NO;
}
 
#define protocol_getName(P) [P name]
#define protocol_isEqual(P,Q) [P isEqual: Q]
 
struct objc_method_description protocol_getMethodDescription (Protocol *protocol,
SEL selector,
BOOL requiredMethod,
BOOL instanceMethod)
{
struct objc_method_description *tmp;
struct objc_method_description result;
 
if (instanceMethod)
tmp = [protocol descriptionForInstanceMethod: selector];
else
tmp = [protocol descriptionForClassMethod: selector];
 
if (tmp)
result = *tmp;
else
{
result.name = (SEL)0;
result.types = (char *)0;
}
 
return result;
}
 
# endif /* NEXT_OBJC_USE_NEW_INTERFACE */
 
# endif /* __NEXT_RUNTIME__ */
 
#endif /* _TESTSUITE_RUNTIME_H_ */
 
/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class.h
0,0 → 1,51
/* A small NSConstantString implementation for use with the NeXT runtime.
Copyright (C) 2011 Free Software Foundation, Inc.
 
This file is part of GCC.
 
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
 
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
 
#ifndef _test_suite_nsconstantstring_class_h_
#define _test_suite_nsconstantstring_class_h_
#ifdef __NEXT_RUNTIME__
 
/* On full-fledged Mac OS X systems, NSConstantString is provided
as part of the Foundation framework. However, on bare Darwin systems,
Foundation is not included, and hence there is no NSConstantString
implementation to link against.
 
This code is derived from the GNU runtime's NXConstantString implementation.
*/
 
#include "objc-test-suite-types.h"
 
extern TNS_STRING_REF_T _NSConstantStringClassReference;
 
@interface NSConstantString
{
Class isa;
char *c_string;
unsigned int len;
}
 
+ (id) initialize;
 
- (const char *) cString;
- (unsigned int) length;
 
@end
 
#endif /* __NEXT_RUNTIME__ */
#endif /* _test_suite_nsconstantstring_class_h_ */
/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/TestsuiteObject.m
0,0 → 1,69
/* Very simple root class for writing testcases.
Copyright (C) 2011 Free Software Foundation, Inc.
Contributed by Nicola Pero
 
This file is part of GCC.
 
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
 
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
 
/* This is the implementation, but in all simple testcases we
recommend simply including it in the testcase. */
 
#include "TestsuiteObject.h"
#include "runtime.h"
 
@implementation TestsuiteObject
+ (id) initialize
{
return self;
}
+ (id) new
{
return [[self alloc] init];
}
+ (id) alloc
{
return class_createInstance (self, 0);
}
- (id) init
{
return self;
}
/* We return 'id' to have the same signature as [Object -free] in
older runtimes and avoid warnings about conflicting signatures. */
- (id) free
{
/* Cast 'self' to 'id' because the NeXT runtime in darwin8 (Apple
Mac OS X 10.4) declares object_dispose to take an "Object *"
argument. */
return object_dispose ((id)self);
}
+ (Class) class
{
return self;
}
+ (Class) superclass
{
return class_getSuperclass (self);
}
+ (const char *)name
{
return class_getName (self);
}
- (const char *)name
{
return class_getName (isa);
}
@end
/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.mm
0,0 → 1,3
/* Allow code to be shared between the FEs but avoid issues with
C++-only flags. */
#include "nsconstantstring-class-impl.h"
/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/next-abi.h
0,0 → 1,64
/* Check which version of the API and ABI are appropriate for the target.
Copyright (C) 2010, 2011 Free Software Foundation, Inc.
 
Contributed by Iain Sandoe <iains@gcc.gnu.org>
 
This file is part of GCC.
 
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
 
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
 
#ifndef _OBJC_NEXT_ABI_H_
#define _OBJC_NEXT_ABI_H_
/* Produce a define that allows us to figure out what facilities are
available for this gcc and OS combination.
*/
 
/* By default we do nothing - therefore ifdef NEXT_OBJC_USE_NEW_INTERFACE
* is reliable for detecting versions of the target that require either
* API=2, or both API & ABI = 2 (m64 code).
*
* This applies for versions of OSX >= 10.5 (darwin9).
*
* A compiler capable of producing ObjC V2 ABI should define __OBJC2__
*/
 
#undef NEXT_OBJC_ABI_VERSION
#undef NEXT_OBJC_USE_NEW_INTERFACE
 
#ifdef __NEXT_RUNTIME__
# if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 || __OBJC2__)
/* We have to use an updated interface for 32bit NeXT to avoid
* 'deprecated' warnings.
* For 64bit NeXT the ABI is different (and the interfaces 'deprecated'
* for 32bit have been removed).
*/
# define NEXT_OBJC_USE_NEW_INTERFACE 1
# if __OBJC2__ || __LP64__
/* We have OBJC v2 ABI compiler,
(or, at least, the available NeXT runtime requires one) */
# define NEXT_OBJC_ABI_VERSION 2
# else
/* We leave it open to define ABI 1 if and when we implement those
* extensions.
*/
# define NEXT_OBJC_ABI_VERSION 0
# endif
# else
/* Pre-OSX 10.5 all is ABI 0. */
# define NEXT_OBJC_ABI_VERSION 0
# endif /* MAC_OS_X_VERSION_MIN_REQUIRED > 10.5 or OBJC2 */
#endif /* __NEXT_RUNTIME__ */
 
#endif /* _OBJC_NEXT_ABI_H_ */
/or1k-gcc/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.m
0,0 → 1,3
/* Allow code to be shared between the FEs but avoid issues with
C++-only flags. */
#include "nsconstantstring-class-impl.h"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.