+ struct obstack *o = &obst;
+
+ assert(is_declaration(entity));
+
+ if (entity->kind == ENTITY_FUNCTION) {
+ type_t *type = skip_typeref(entity->declaration.type);
+ assert(is_type_function(type));
+
+ if (entity->declaration.modifiers & DM_DLLIMPORT)
+ /* add prefix for imported symbols */
+ obstack_printf(o, "__imp_");
+
+ cc_kind_t cc = type->function.calling_convention;
+
+ /* calling convention prefix */
+ switch (cc) {
+ case CC_DEFAULT:
+ case CC_CDECL:
+ case CC_STDCALL: obstack_1grow(o, '_'); break;
+ case CC_FASTCALL: obstack_1grow(o, '@'); break;
+ default: panic("unhandled calling convention");
+ }
+
+ switch (type->function.linkage) {
+ case LINKAGE_C:
+ obstack_printf(o, "%s", entity->base.symbol->string);
+ break;
+
+ case LINKAGE_CXX:
+ mangle_entity(entity);
+ break;
+ }