| 1 | /* $Id: 572c.c 1232 2004-02-12 15:21:45Z bird $ */ | 
|---|
| 2 | /** @file | 
|---|
| 3 | * | 
|---|
| 4 | * _Optlink declaration and definition testcases. | 
|---|
| 5 | * | 
|---|
| 6 | * InnoTek Systemberatung GmbH confidential | 
|---|
| 7 | * | 
|---|
| 8 | * Copyright (c) 2003 InnoTek Systemberatung GmbH | 
|---|
| 9 | * Author: knut st. osmundsen <bird-srcspam@anduin.net> | 
|---|
| 10 | * | 
|---|
| 11 | * All Rights Reserved | 
|---|
| 12 | * | 
|---|
| 13 | */ | 
|---|
| 14 | typedef struct some_struct_pointer * PTYPE; | 
|---|
| 15 |  | 
|---|
| 16 | /* | 
|---|
| 17 | * Function and method declarations. | 
|---|
| 18 | * Checks mangling. | 
|---|
| 19 | */ | 
|---|
| 20 | /* No underscore, No mangling. */ | 
|---|
| 21 | void    _Optlink            CVoid(int a, int b, int c, int d); | 
|---|
| 22 | void *  _Optlink            CPVoid(int a, int b, int c, int d); | 
|---|
| 23 | int     _Optlink            CInt(int a, int b, int c, int d); | 
|---|
| 24 | PTYPE   _Optlink            CPType(int a, int b, int c, int d); | 
|---|
| 25 |  | 
|---|
| 26 | /* | 
|---|
| 27 | * Typedefs. | 
|---|
| 28 | * Checks that there is not warnings on these. | 
|---|
| 29 | */ | 
|---|
| 30 | typedef void    _Optlink    Typedef1Void(int a, int b, int c, int d); | 
|---|
| 31 | typedef void *  _Optlink    Typedef1PVoid(int a, int b, int c, int d); | 
|---|
| 32 | typedef int     _Optlink    Typedef1Int(int a, int b, int c, int d); | 
|---|
| 33 | typedef PTYPE   _Optlink    Typedef1PType(int a, int b, int c, int d); | 
|---|
| 34 |  | 
|---|
| 35 | typedef void    (_Optlink   Typedef2Void)(int a, int b, int c, int d); | 
|---|
| 36 | typedef void *  (_Optlink   Typedef2PVoid)(int a, int b, int c, int d); | 
|---|
| 37 | typedef int     (_Optlink   Typedef2Int)(int a, int b, int c, int d); | 
|---|
| 38 | typedef PTYPE   (_Optlink   Typedef2PType)(int a, int b, int c, int d); | 
|---|
| 39 | #ifdef __EMX__ | 
|---|
| 40 | typedef void    _Optlink   (Typedef3Void)(int a, int b, int c, int d); | 
|---|
| 41 | typedef void *  _Optlink   (Typedef3PVoid)(int a, int b, int c, int d); | 
|---|
| 42 | typedef int     _Optlink   (Typedef3Int)(int a, int b, int c, int d); | 
|---|
| 43 | typedef PTYPE   _Optlink   (Typedef3PType)(int a, int b, int c, int d); | 
|---|
| 44 | #endif | 
|---|
| 45 |  | 
|---|
| 46 | typedef void    (* _Optlink PTypedef1Void)(int a, int b, int c, int d); | 
|---|
| 47 | typedef void *  (* _Optlink PTypedef1PVoid)(int a, int b, int c, int d); | 
|---|
| 48 | typedef int     (* _Optlink PTypedef1Int)(int a, int b, int c, int d); | 
|---|
| 49 | typedef PTYPE   (* _Optlink PTypedef1PType)(int a, int b, int c, int d); | 
|---|
| 50 |  | 
|---|
| 51 | /* Alternate writing which should have the same effect I think... */ | 
|---|
| 52 | typedef void    (_Optlink * PTypedef2Void)(int a, int b, int c, int d); | 
|---|
| 53 | typedef void *  (_Optlink * PTypedef2PVoid)(int a, int b, int c, int d); | 
|---|
| 54 | typedef int     (_Optlink * PTypedef2Int)(int a, int b, int c, int d); | 
|---|
| 55 | typedef PTYPE   (_Optlink * PTypedef2PType)(int a, int b, int c, int d); | 
|---|
| 56 | #ifdef __EMX__ | 
|---|
| 57 | /* Alternate writing which should have the same effect I think... */ | 
|---|
| 58 | typedef void    _Optlink (* PTypedef3Void)(int a, int b, int c, int d); | 
|---|
| 59 | typedef void *  _Optlink (* PTypedef3PVoid)(int a, int b, int c, int d); | 
|---|
| 60 | typedef int     _Optlink (* PTypedef3Int)(int a, int b, int c, int d); | 
|---|
| 61 | typedef PTYPE   _Optlink (* PTypedef3PType)(int a, int b, int c, int d); | 
|---|
| 62 | #endif | 
|---|
| 63 |  | 
|---|
| 64 | /* | 
|---|
| 65 | * Structures. | 
|---|
| 66 | */ | 
|---|
| 67 | typedef struct VFT | 
|---|
| 68 | { | 
|---|
| 69 | void    (_Optlink * PStructMemberVoid)(int a, int b, int c, int d); | 
|---|
| 70 | void *  (_Optlink * PStructMemberPVoid)(int a, int b, int c, int d); | 
|---|
| 71 | int     (_Optlink * PStructMemberInt)(int a, int b, int c, int d); | 
|---|
| 72 | PTYPE   (_Optlink * PStructMemberPType)(int a, int b, int c, int d); | 
|---|
| 73 |  | 
|---|
| 74 | /* Alternate writing which should have the same effect I think... */ | 
|---|
| 75 | void    (_Optlink * PStructMember2Void)(int a, int b, int c, int d); | 
|---|
| 76 | void *  (_Optlink * PStructMember2PVoid)(int a, int b, int c, int d); | 
|---|
| 77 | int     (_Optlink * PStructMember2Int)(int a, int b, int c, int d); | 
|---|
| 78 | PTYPE   (_Optlink * PStructMember2PType)(int a, int b, int c, int d); | 
|---|
| 79 |  | 
|---|
| 80 | #ifdef __EMX__ | 
|---|
| 81 | /* Alternate writing which should have the same effect I think... */ | 
|---|
| 82 | void    _Optlink (* PStructMember3Void)(int a, int b, int c, int d); | 
|---|
| 83 | void *  _Optlink (* PStructMember3PVoid)(int a, int b, int c, int d); | 
|---|
| 84 | int     _Optlink (* PStructMember3Int)(int a, int b, int c, int d); | 
|---|
| 85 | PTYPE   _Optlink (* PStructMember3PType)(int a, int b, int c, int d); | 
|---|
| 86 | #endif | 
|---|
| 87 | } VFT, *PVFT; | 
|---|
| 88 |  | 
|---|
| 89 |  | 
|---|
| 90 | /* | 
|---|
| 91 | * Variables | 
|---|
| 92 | */ | 
|---|
| 93 | void    (* _Optlink PVar1Void)(int a, int b, int c, int d); | 
|---|
| 94 | void *  (* _Optlink PVar1PVoid)(int a, int b, int c, int d); | 
|---|
| 95 | int     (* _Optlink PVar1Int)(int a, int b, int c, int d); | 
|---|
| 96 | PTYPE   (* _Optlink PVar1PType)(int a, int b, int c, int d); | 
|---|
| 97 |  | 
|---|
| 98 | /* Alternate writing which should have the same effect I think... */ | 
|---|
| 99 | void    (_Optlink * PVar2Void)(int a, int b, int c, int d); | 
|---|
| 100 | void *  (_Optlink * PVar2PVoid)(int a, int b, int c, int d); | 
|---|
| 101 | int     (_Optlink * PVar2Int)(int a, int b, int c, int d); | 
|---|
| 102 | PTYPE   (_Optlink * PVar2PType)(int a, int b, int c, int d); | 
|---|
| 103 |  | 
|---|
| 104 | #ifdef __EMX__ | 
|---|
| 105 | void    _Optlink (* PVar3Void)(int a, int b, int c, int d); | 
|---|
| 106 | void *  _Optlink (* PVar3PVoid)(int a, int b, int c, int d); | 
|---|
| 107 | int     _Optlink (* PVar3Int)(int a, int b, int c, int d); | 
|---|
| 108 | PTYPE   _Optlink (* PVar3PType)(int a, int b, int c, int d); | 
|---|
| 109 | #endif | 
|---|
| 110 |  | 
|---|
| 111 |  | 
|---|
| 112 | /* | 
|---|
| 113 | * Parameters. | 
|---|
| 114 | */ | 
|---|
| 115 | int ParamArgs( | 
|---|
| 116 | void    (* _Optlink pfn1Void)(int a, int b, int c, int d), | 
|---|
| 117 | void *  (* _Optlink pfn1PVoid)(int a, int b, int c, int d), | 
|---|
| 118 | int     (* _Optlink pfn1Int)(int a, int b, int c, int d), | 
|---|
| 119 | PTYPE   (* _Optlink pfn1PType)(int a, int b, int c, int d), | 
|---|
| 120 | void    (_Optlink * pfn2Void)(int a, int b, int c, int d), | 
|---|
| 121 | void *  (_Optlink * pfn2PVoid)(int a, int b, int c, int d), | 
|---|
| 122 | int     (_Optlink * pfn2Int)(int a, int b, int c, int d), | 
|---|
| 123 | PTYPE   (_Optlink * pfn2PType)(int a, int b, int c, int d) | 
|---|
| 124 | #ifdef __EMX__ | 
|---|
| 125 | , | 
|---|
| 126 | void    _Optlink (* pfn3Void)(int a, int b, int c, int d), | 
|---|
| 127 | void *  _Optlink (* pfn3PVoid)(int a, int b, int c, int d), | 
|---|
| 128 | int     _Optlink (* pfn3Int)(int a, int b, int c, int d), | 
|---|
| 129 | PTYPE   _Optlink (* pfn3PType)(int a, int b, int c, int d) | 
|---|
| 130 | #endif | 
|---|
| 131 | ) | 
|---|
| 132 | { | 
|---|
| 133 | pfn1Void(1,2,3,4); | 
|---|
| 134 | pfn1PVoid(1,2,3,4); | 
|---|
| 135 | pfn1Int(1,2,3,4); | 
|---|
| 136 | pfn1PType(1,2,3,4); | 
|---|
| 137 |  | 
|---|
| 138 | pfn2Void(1,2,3,4); | 
|---|
| 139 | pfn2PVoid(1,2,3,4); | 
|---|
| 140 | pfn2Int(1,2,3,4); | 
|---|
| 141 | pfn2PType(1,2,3,4); | 
|---|
| 142 |  | 
|---|
| 143 | #ifdef __EMX__ | 
|---|
| 144 | pfn3Void(1,2,3,4); | 
|---|
| 145 | pfn3PVoid(1,2,3,4); | 
|---|
| 146 | pfn3Int(1,2,3,4); | 
|---|
| 147 | pfn3PType(1,2,3,4); | 
|---|
| 148 | #endif | 
|---|
| 149 | return 0; | 
|---|
| 150 | } | 
|---|
| 151 |  | 
|---|
| 152 | /* @todo: extend and fix this */ | 
|---|
| 153 | extern void ParamArgs_1(void (_Optlink *)(void)); | 
|---|
| 154 | extern void ParamArgs_2(void (* _Optlink fixme) (void)); | 
|---|
| 155 | #ifdef __EMX__ | 
|---|
| 156 | extern void ParamArgs_3(void _Optlink (*)(void)); | 
|---|
| 157 | #endif | 
|---|
| 158 |  | 
|---|
| 159 |  | 
|---|
| 160 | int DoC(int a, int b, int c, int d) | 
|---|
| 161 | { | 
|---|
| 162 | static VFT vft = {CVoid, CPVoid, CInt, CPType, | 
|---|
| 163 | #ifdef __EMX__ | 
|---|
| 164 | CVoid, CPVoid, CInt, CPType, | 
|---|
| 165 | #endif | 
|---|
| 166 | CVoid, CPVoid, CInt, CPType}; | 
|---|
| 167 |  | 
|---|
| 168 | static Typedef1Void       * pfnTypedef1Void   = CVoid; | 
|---|
| 169 | static Typedef1PVoid      * pfnTypedef1PVoid  = CPVoid; | 
|---|
| 170 | static Typedef1Int        * pfnTypedef1Int    = CInt; | 
|---|
| 171 | static Typedef1PType      * pfnTypedef1PType  = CPType; | 
|---|
| 172 |  | 
|---|
| 173 | static Typedef2Void       * pfnTypedef2Void   = CVoid; | 
|---|
| 174 | static Typedef2PVoid      * pfnTypedef2PVoid  = CPVoid; | 
|---|
| 175 | static Typedef2Int        * pfnTypedef2Int    = CInt; | 
|---|
| 176 | static Typedef2PType      * pfnTypedef2PType  = CPType; | 
|---|
| 177 | #ifdef __EMX__ | 
|---|
| 178 | static Typedef3Void       * pfnTypedef3Void   = CVoid; | 
|---|
| 179 | static Typedef3PVoid      * pfnTypedef3PVoid  = CPVoid; | 
|---|
| 180 | static Typedef3Int        * pfnTypedef3Int    = CInt; | 
|---|
| 181 | static Typedef3PType      * pfnTypedef3PType  = CPType; | 
|---|
| 182 | #endif | 
|---|
| 183 |  | 
|---|
| 184 | static PTypedef1Void        pfnPTypedef1Void  = CVoid; | 
|---|
| 185 | static PTypedef1PVoid       pfnPTypedef1PVoid = CPVoid; | 
|---|
| 186 | static PTypedef1Int         pfnPTypedef1Int   = CInt; | 
|---|
| 187 | static PTypedef1PType       pfnPTypedef1PType = CPType; | 
|---|
| 188 |  | 
|---|
| 189 | static PTypedef2Void        pfnPTypedef2Void  = CVoid; | 
|---|
| 190 | static PTypedef2PVoid       pfnPTypedef2PVoid = CPVoid; | 
|---|
| 191 | static PTypedef2Int         pfnPTypedef2Int   = CInt; | 
|---|
| 192 | static PTypedef2PType       pfnPTypedef2PType = CPType; | 
|---|
| 193 |  | 
|---|
| 194 | #ifdef __EMX__ | 
|---|
| 195 | static PTypedef3Void        pfnPTypedef3Void  = CVoid; | 
|---|
| 196 | static PTypedef3PVoid       pfnPTypedef3PVoid = CPVoid; | 
|---|
| 197 | static PTypedef3Int         pfnPTypedef3Int   = CInt; | 
|---|
| 198 | static PTypedef3PType       pfnPTypedef3PType = CPType; | 
|---|
| 199 | #endif | 
|---|
| 200 |  | 
|---|
| 201 | PVar1Void   = CVoid; | 
|---|
| 202 | PVar1PVoid  = CPVoid; | 
|---|
| 203 | PVar1Int    = CInt; | 
|---|
| 204 | PVar1PType  = CPType; | 
|---|
| 205 |  | 
|---|
| 206 | PVar2Void   = CVoid; | 
|---|
| 207 | PVar2PVoid  = CPVoid; | 
|---|
| 208 | PVar2Int    = CInt; | 
|---|
| 209 | PVar2PType  = CPType; | 
|---|
| 210 |  | 
|---|
| 211 | #ifdef __EMX__ | 
|---|
| 212 | PVar3Void   = CVoid; | 
|---|
| 213 | PVar3PVoid  = CPVoid; | 
|---|
| 214 | PVar3Int    = CInt; | 
|---|
| 215 | PVar3PType  = CPType; | 
|---|
| 216 | #endif | 
|---|
| 217 |  | 
|---|
| 218 | /* extern functions */ | 
|---|
| 219 | CVoid(1,2,3,4); | 
|---|
| 220 | CPVoid(1,2,3,4); | 
|---|
| 221 | CInt(1,2,3,4); | 
|---|
| 222 | CPType(1,2,3,4); | 
|---|
| 223 |  | 
|---|
| 224 | /* typedefs */ | 
|---|
| 225 | pfnTypedef1Void(1,2,3,4); | 
|---|
| 226 | pfnTypedef1PVoid(1,2,3,4); | 
|---|
| 227 | pfnTypedef1Int(1,2,3,4); | 
|---|
| 228 | pfnTypedef1PType(1,2,3,4); | 
|---|
| 229 |  | 
|---|
| 230 | pfnTypedef2Void(1,2,3,4); | 
|---|
| 231 | pfnTypedef2PVoid(1,2,3,4); | 
|---|
| 232 | pfnTypedef2Int(1,2,3,4); | 
|---|
| 233 | pfnTypedef2PType(1,2,3,4); | 
|---|
| 234 |  | 
|---|
| 235 | #ifdef __EMX__ | 
|---|
| 236 | pfnTypedef3Void(1,2,3,4); | 
|---|
| 237 | pfnTypedef3PVoid(1,2,3,4); | 
|---|
| 238 | pfnTypedef3Int(1,2,3,4); | 
|---|
| 239 | pfnTypedef3PType(1,2,3,4); | 
|---|
| 240 | #endif | 
|---|
| 241 |  | 
|---|
| 242 | pfnPTypedef1Void(1,2,3,4); | 
|---|
| 243 | pfnPTypedef1PVoid(1,2,3,4); | 
|---|
| 244 | pfnPTypedef1Int(1,2,3,4); | 
|---|
| 245 | pfnPTypedef1PType(1,2,3,4); | 
|---|
| 246 |  | 
|---|
| 247 | pfnPTypedef2Void(1,2,3,4); | 
|---|
| 248 | pfnPTypedef2PVoid(1,2,3,4); | 
|---|
| 249 | pfnPTypedef2Int(1,2,3,4); | 
|---|
| 250 | pfnPTypedef2PType(1,2,3,4); | 
|---|
| 251 |  | 
|---|
| 252 | #ifdef __EMX__ | 
|---|
| 253 | pfnPTypedef3Void(1,2,3,4); | 
|---|
| 254 | pfnPTypedef3PVoid(1,2,3,4); | 
|---|
| 255 | pfnPTypedef3Int(1,2,3,4); | 
|---|
| 256 | pfnPTypedef3PType(1,2,3,4); | 
|---|
| 257 | #endif | 
|---|
| 258 |  | 
|---|
| 259 | /* structs */ | 
|---|
| 260 | vft.PStructMemberVoid(1,2,3,4); | 
|---|
| 261 | vft.PStructMemberPVoid(1,2,3,4); | 
|---|
| 262 | vft.PStructMemberInt(1,2,3,4); | 
|---|
| 263 | vft.PStructMemberPType(1,2,3,4); | 
|---|
| 264 |  | 
|---|
| 265 | vft.PStructMember2Void(1,2,3,4); | 
|---|
| 266 | vft.PStructMember2PVoid(1,2,3,4); | 
|---|
| 267 | vft.PStructMember2Int(1,2,3,4); | 
|---|
| 268 | vft.PStructMember2PType(1,2,3,4); | 
|---|
| 269 |  | 
|---|
| 270 | #ifdef __EMX__ | 
|---|
| 271 | vft.PStructMember3Void(1,2,3,4); | 
|---|
| 272 | vft.PStructMember3PVoid(1,2,3,4); | 
|---|
| 273 | vft.PStructMember3Int(1,2,3,4); | 
|---|
| 274 | vft.PStructMember3PType(1,2,3,4); | 
|---|
| 275 | #endif | 
|---|
| 276 |  | 
|---|
| 277 | /* variables */ | 
|---|
| 278 | PVar1Void(1,2,3,4); | 
|---|
| 279 | PVar1PVoid(1,2,3,4); | 
|---|
| 280 | PVar1Int(1,2,3,4); | 
|---|
| 281 | PVar1PType(1,2,3,4); | 
|---|
| 282 |  | 
|---|
| 283 | PVar2Void(1,2,3,4); | 
|---|
| 284 | PVar2PVoid(1,2,3,4); | 
|---|
| 285 | PVar2Int(1,2,3,4); | 
|---|
| 286 | PVar2PType(1,2,3,4); | 
|---|
| 287 |  | 
|---|
| 288 | /* parameters */ | 
|---|
| 289 | ParamArgs(CVoid, CPVoid, CInt, CPType, | 
|---|
| 290 | #ifdef __EMX__ | 
|---|
| 291 | CVoid, CPVoid, CInt, CPType, | 
|---|
| 292 | #endif | 
|---|
| 293 | CVoid, CPVoid, CInt, CPType); | 
|---|
| 294 |  | 
|---|
| 295 | return 0; | 
|---|
| 296 | } | 
|---|
| 297 |  | 
|---|