/* * Copyright (c) 1997, 1998, 1999 The University of Utah and * the Computer Systems Laboratory at the University of Utah (CSL). * * This file is part of Flick, the Flexible IDL Compiler Kit. * * Flick 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 2 of the License, or * (at your option) any later version. * * Flick 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 Flick; see the file COPYING. If not, write to * the Free Software Foundation, 59 Temple Place #330, Boston, MA 02111, USA. */ /* * This file contains the server function definitions for mig-tests.defs. */ #include #include #include #include #include #include #include #include #include #include "mig-tests-server.h" /* * Server functions */ /* * InLine tests */ /* multiply in * inout, return in out and inout */ kern_return_t s_inline_integers(mach_port_t target, Iint inInt, Iint *inoutInt, Iint *outInt) { *outInt = inInt * (*inoutInt); *inoutInt = *outInt; return KERN_SUCCESS; } /* struct copy inout to out and in to inout */ kern_return_t s_inline_fixed_structs(mach_port_t target, IFstruct inStruct, IFstruct *inoutStruct, IFstruct *outStruct) { *outStruct = *inoutStruct; *inoutStruct = inStruct; return KERN_SUCCESS; } /* multiply each in element by corresponding inout element, return in both inout and out */ kern_return_t s_inline_fixed_arrays(mach_port_t target, IFarray inArray, IFarray inoutArray, IFarray outArray) { int i; for (i=0; i<300; i++) { outArray[i] = inArray[i] * inoutArray[i]; inoutArray[i] = outArray[i]; } return KERN_SUCCESS; } /* element-by-element copy of in to out */ kern_return_t s_inline_bounded_arrays(mach_port_t target, IBarray inArray, mach_msg_type_number_t inArrayCnt, IBarray outArray, mach_msg_type_number_t *outArrayCnt) { int i; for (i=0; i\n", (int)inInt, *inInt, (int)*inoutInt, **inoutInt); #endif if (inInt == NULL || inoutInt == NULL || *inoutInt == NULL) return MIG_REMOTE_ERROR; vm_allocate(mach_task_self(), (vm_address_t *) outInt, sizeof(int), 1); **outInt = **inoutInt * *inInt; **inoutInt = **outInt; #if 0 printf("Set inInt=0x%08x,%d, inoutInt=0x%08x,%d, outInt=0x%08x,%d\n", (int)inInt, *inInt, (int)*inoutInt, **inoutInt, (int)*outInt, **outInt); #endif return KERN_SUCCESS; } /* struct copy inout to out and in to inout */ kern_return_t s_outline_fixed_structs(mach_port_t target, OFstruct inStruct, OFstruct *inoutStruct, OFstruct *outStruct) { if (inStruct == NULL || inoutStruct == NULL || *inoutStruct == NULL) return MIG_REMOTE_ERROR; vm_allocate(mach_task_self(), (vm_address_t *) outStruct, sizeof(*inStruct), 1); **outStruct = **inoutStruct; **inoutStruct = *inStruct; return KERN_SUCCESS; } /* multiply each in element by corresponding inout element, return in both inout and out */ kern_return_t s_outline_fixed_arrays(mach_port_t target, OFarray inArray, OFarray *inoutArray, OFarray *outArray) { int i; if (inArray == NULL || inoutArray == NULL || *inoutArray == NULL) return MIG_REMOTE_ERROR; vm_allocate(mach_task_self(), (vm_address_t *) outArray, sizeof(int)*400, 1); for (i=0; i<400; i++) { (**outArray)[i] = (*inArray)[i] * (**inoutArray)[i]; (**inoutArray)[i] = (**outArray)[i]; } return KERN_SUCCESS; } /* element-by-element copy of inout to out and in to inout */ kern_return_t s_outline_unbounded_arrays(mach_port_t target, Oarray inArray, mach_msg_type_number_t inArrayCnt, Oarray *inoutArray, mach_msg_type_number_t *inoutArrayCnt, Oarray *outArray, mach_msg_type_number_t *outArrayCnt) { int i, min; if (inArray == NULL || inoutArray == NULL || *inoutArray == NULL) return MIG_REMOTE_ERROR; vm_allocate(mach_task_self(), (vm_address_t *) outArray, sizeof(int) * *inoutArrayCnt, 1); for (i=0; i<*inoutArrayCnt; i++) { (*outArray)[i] = (*inoutArray)[i]; } *outArrayCnt = *inoutArrayCnt; min = (inArrayCnt < *inoutArrayCnt)? inArrayCnt : *inoutArrayCnt; for (i=0; i 50) *outArrayCnt = 50; vm_allocate(mach_task_self(), (vm_address_t *) outArray, sizeof(int) * *outArrayCnt, 1); for (i = 0; i < *outArrayCnt; i++) (*outArray)[i] = i; return KERN_SUCCESS; } /* element-by-element copy of inout to out and in to inout */ kern_return_t s_test_dealloc_pointer(mach_port_t target, Oarray inArray, mach_msg_type_number_t inArrayCnt, Oarray *inoutArray, mach_msg_type_number_t *inoutArrayCnt, Oarray *outArray, mach_msg_type_number_t *outArrayCnt) { int i, min; if (inArray == NULL || inoutArray == NULL || *inoutArray == NULL) return MIG_REMOTE_ERROR; vm_allocate(mach_task_self(), (vm_address_t *) outArray, sizeof(int) * *inoutArrayCnt, 1); for (i=0; i<*inoutArrayCnt; i++) { (*outArray)[i] = (*inoutArray)[i]; } *outArrayCnt = *inoutArrayCnt; min = (inArrayCnt < *inoutArrayCnt)? inArrayCnt : *inoutArrayCnt; for (i=0; imsgh_size); #endif ret = tests_server(request_ptr, reply_ptr); #if 0 printf("RPC-SND:\n"); print_message(reply_ptr, reply_ptr->msgh_size); printf("Returning from server (%c)...\n",(ret)?'T':'F'); #endif if (!ret) { printf("Server function FAILED!\n"); } return ret; } /* End of file. */