void forward(universal_t *objref) { universal_t *ptr = *((universal_t **)objref); if (is_ptr(ptr) && (ptr >= curbot && ptr < curtop)) { /* ptr is a pointer into an object in fromspace */ if (is_rec(ptr)) { /* Get a pointer to the header */ universal_t *header = hdr(ptr); /* Retrieve the length of the record (plus one for the header) */ universal_t len = rec_len(ptr) + 1; /* Copy the object starting at the header into tosapce */ universal_t *i = header;; universal_t *j = endptr; while (len-- > 0) { *j++ = *i++; } /* Set the forwarding pointer in fromspace and update the record's tag */ *ptr = (universal_t)(endptr + 1); *header = UINTPTR_MAX; /* Move the end of the queue forward */ endptr = j; } /* ptr must be a forwarding pointer. It either already was, or we forwarded it above. Update the objref to point to the new object */ *objref = *(universal_t *)ptr; } }
void print(Value x) { if (is_nil(x)) prints("nil"); else if (is_eof(x)) printf("#eof"); else if (is_fixnum(x)) printf("%d", as_fixnum(x)); else if (is_bool(x)) printf("%s", as_bool(x) ? "true" : "false"); else if (is_char(x)) printf("'%c'", as_char(x)); else if (is_pair(x)) print_list(x); else if (is_symbol(x)) prints(as_symbol(x)->value); else if (is_string(x)) print_string(as_string(x)); else if (is_procedure(x)) printf("#<procedure %s>", as_procedure(x)->name->value); else if (is_module(x)) printf("#<module>"); else if (is_type(x)) printf("#<type %s>", as_type(x)->name->value); else if (is_ptr(x)) printf("#<object %p>", as_ptr(x)); else if (is_undefined(x)) printf("#undefined"); else printf("#ufo"); }
inline basetype_t* get_type_ptr(basetype_t *type) { if ((is_ptr(type->ohm_type) || is_alias(type->ohm_type)) && type->elems) return get_type_ptr(type->elems[0]); return type; }
int main() { char *m="abcdxyzuvwefghijklmn"; int ret; ret = app_memeql(m,"bcd"); printf("%d\n", __builtin_types_compatible_p(typeof("bcd"), typeof(&"bcd"[0]))); printf("%d\n", !memcmp((m), ("bcd"), sizeof("bcd") - 1)); printf("%d\n",is_ptr(m)); printf("%d\n",ret); return 0; }
static void clear_output_vars( const var_list_t *args ) { const var_t *arg; if (!args) return; LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry ) { if (is_attr(arg->attrs, ATTR_IN)) continue; if (!is_attr(arg->attrs, ATTR_OUT)) continue; if (is_ptr(arg->type)) { if (type_get_type(type_pointer_get_ref(arg->type)) == TYPE_BASIC) continue; if (type_get_type(type_pointer_get_ref(arg->type)) == TYPE_ENUM) continue; } print_proxy( "if (%s) MIDL_memset( %s, 0, sizeof( *%s ));\n", arg->name, arg->name, arg->name ); } }
inline const TypeNarrowOop* Type::make_narrowoop() const { return (_base == NarrowOop) ? is_narrowoop() : (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL); }
inline const TypePtr* Type::make_ptr() const { return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() : (isa_ptr() ? is_ptr() : NULL); }
static void gen_proxy(type_t *iface, const var_t *func, int idx, unsigned int proc_offset) { var_t *retval = type_function_get_retval(func->type); int has_ret = !is_void(retval->type); int has_full_pointer = is_full_pointer_function(func); const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV); const var_list_t *args = type_get_function_args(func->type); if (!callconv) callconv = "STDMETHODCALLTYPE"; indent = 0; if (is_interpreted_func( iface, func )) { if (get_stub_mode() == MODE_Oif && !is_callas( func->attrs )) return; write_type_decl_left(proxy, retval->type); print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); write_args(proxy, args, iface->name, 1, TRUE); print_proxy( ")\n"); write_client_call_routine( proxy, iface, func, "Object", proc_offset ); return; } print_proxy( "static void __finally_%s_%s_Proxy( struct __proxy_frame *__frame )\n", iface->name, get_name(func) ); print_proxy( "{\n"); indent++; if (has_full_pointer) write_full_pointer_free(proxy, indent, func); print_proxy( "NdrProxyFreeBuffer( __frame->This, &__frame->_StubMsg );\n" ); indent--; print_proxy( "}\n"); print_proxy( "\n"); write_type_decl_left(proxy, retval->type); print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); write_args(proxy, args, iface->name, 1, TRUE); print_proxy( ")\n"); print_proxy( "{\n"); indent ++; print_proxy( "struct __proxy_frame __f, * const __frame = &__f;\n" ); /* local variables */ if (has_ret) { print_proxy( "%s", "" ); write_type_decl(proxy, retval->type, retval->name); fprintf( proxy, ";\n" ); } print_proxy( "RPC_MESSAGE _RpcMessage;\n" ); if (has_ret) { if (decl_indirect(retval->type)) print_proxy("void *_p_%s = &%s;\n", retval->name, retval->name); } print_proxy( "\n"); print_proxy( "RpcExceptionInit( __proxy_filter, __finally_%s_%s_Proxy );\n", iface->name, get_name(func) ); print_proxy( "__frame->This = This;\n" ); if (has_full_pointer) write_full_pointer_init(proxy, indent, func, FALSE); /* FIXME: trace */ clear_output_vars( type_get_function_args(func->type) ); print_proxy( "RpcTryExcept\n" ); print_proxy( "{\n" ); indent++; print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &__frame->_StubMsg, &Object_StubDesc, %d);\n", idx); write_pointer_checks( proxy, indent, func ); print_proxy( "RpcTryFinally\n" ); print_proxy( "{\n" ); indent++; write_remoting_arguments(proxy, indent, func, "", PASS_IN, PHASE_BUFFERSIZE); print_proxy( "NdrProxyGetBuffer(This, &__frame->_StubMsg);\n" ); write_remoting_arguments(proxy, indent, func, "", PASS_IN, PHASE_MARSHAL); print_proxy( "NdrProxySendReceive(This, &__frame->_StubMsg);\n" ); fprintf(proxy, "\n"); print_proxy( "__frame->_StubMsg.BufferStart = _RpcMessage.Buffer;\n" ); print_proxy( "__frame->_StubMsg.BufferEnd = __frame->_StubMsg.BufferStart + _RpcMessage.BufferLength;\n\n" ); print_proxy("if ((_RpcMessage.DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n"); indent++; print_proxy("NdrConvert( &__frame->_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset ); indent--; fprintf(proxy, "\n"); write_remoting_arguments(proxy, indent, func, "", PASS_OUT, PHASE_UNMARSHAL); if (has_ret) { if (decl_indirect(retval->type)) print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", retval->name, retval->name); else if (is_ptr(retval->type) || is_array(retval->type)) print_proxy("%s = 0;\n", retval->name); write_remoting_arguments(proxy, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL); } indent--; print_proxy( "}\n"); print_proxy( "RpcFinally\n" ); print_proxy( "{\n" ); indent++; print_proxy( "__finally_%s_%s_Proxy( __frame );\n", iface->name, get_name(func) ); indent--; print_proxy( "}\n"); print_proxy( "RpcEndFinally\n" ); indent--; print_proxy( "}\n" ); print_proxy( "RpcExcept(__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE)\n" ); print_proxy( "{\n" ); if (has_ret) { indent++; proxy_free_variables( type_get_function_args(func->type), "" ); print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" ); indent--; } print_proxy( "}\n" ); print_proxy( "RpcEndExcept\n" ); if (has_ret) { print_proxy( "return _RetVal;\n" ); } indent--; print_proxy( "}\n"); print_proxy( "\n"); }
int is_var_ptr(const var_t *v) { return is_ptr(v->type); }