/* * _mr_locsw_set(mr_info, usersw, count) finds an unused entry in the * structure describing outstanding asynchronous I/O * requests, and initializes its values. * Parameters: usersw - address of the status word passed in from the * upper level. * count - number of BITS already completed for this request. * * Returns: pointer to the _lociosw structure to be used. * NULL if error occurred */ _lociosw * _mr_locsw_set( struct mr_f *mr_info, struct ffsw *usersw, int count) { _lociosw *locptr; int i; struct _loclink *loclink; MEM_LOCK(&(mr_info->locsw_lock)); if (mr_info->loclist == NULL) { mr_info->loclist = (struct _loclink *)calloc(1, sizeof(struct _loclink)); if (mr_info->loclist == NULL) { goto nomem; } } loclink = mr_info->loclist; locptr = loclink->loc_first; for (;;) { for (i = 0; i < _FSSASYNUM ; i++) { if (locptr->user_sw == NULL) { goto found ; } else locptr++; } if (loclink->loc_nxt == NULL) { loclink->loc_nxt = (struct _loclink *)calloc(1, sizeof(struct _loclink)); if (loclink->loc_nxt == NULL) { goto nomem; } } loclink = loclink->loc_nxt; locptr = loclink->loc_first; } found: locptr->user_sw = usersw; locptr->sw_count = count; CLRFFSTAT(*usersw); memset(&locptr->local_sw , 0, sizeof(struct ffsw)); #if defined(_ADDR64) || defined(__mips) usersw->sw_sptr = (void *)locptr; #else usersw->sw_sptr = (int)locptr; #endif MEM_UNLOCK(&(mr_info->locsw_lock)); return(locptr); nomem: MEM_UNLOCK(&(mr_info->locsw_lock)); return(NULL); }
int sigtrbk(FILE *stream, int depth) { long stat; FILE *f; if (_numargs() > 0) /* If stream specified */ f = stream; else f = stderr; MEM_LOCK(&traceback_lock); if (_numargs() > 1) /* If depth specified */ _trbkdpth = depth; else { char *env; if (env = getenv("TRBKDPTH")) _trbkdpth = atoi(env); } /* Flush all files */ if (LOADED(fflush)) (void) fflush(NULL); stat = _trbk(fileno(f), _sigarea()); MEM_UNLOCK(&traceback_lock); return((int)stat); }
long TRBK(long *depth) { long stat; MEM_LOCK(&traceback_lock); if (_numargs() > 0) /* If depth specified */ _trbkdpth = *depth; else { char *env; if (env = getenv("TRBKDPTH")) _trbkdpth = atoi(env); } /* Flush all files */ if (LOADED(fflush)) (void) fflush(NULL); stat = _trbk(fileno(stderr)); MEM_UNLOCK(&traceback_lock); return(stat); }
/* Free the memory allocated for the sk_list */ int sk_free() { SK_P FAR *sk_ptr; ll_access(&sk_list); while ((sk_ptr = (SK_P FAR *)ll_next(&sk_list)) != NULL) { MEM_UNLOCK(&sk_ptr->ptr->sk_val); FREE(&sk_ptr->ptr->sk_val); } ll_deaccess(&sk_list); ll_free(&sk_list); return( db_status ); }
long $TRBK() { long stat; char *env; MEM_LOCK(&traceback_lock); if (env = getenv("TRBKDPTH")) _trbkdpth = atoi(env); /* Flush all files */ if (LOADED(fflush)) (void) fflush(NULL); stat = _trbk(fileno(stderr)); MEM_UNLOCK(&traceback_lock); return(stat); }
/* Provide this to implement intrinsic without polluting Fortran namespace. */ float pathf90_dtime (float tarray[2]) { float utime, stime; static float old_utime = 0.0, old_stime = 0.0; static plock_t mut = PTHREAD_MUTEX_INITIALIZER; struct rusage rbuff; MEM_LOCK(&mut); if (getrusage (RUSAGE_SELF, &rbuff) != 0) abort (); utime = (float) (rbuff.ru_utime).tv_sec + (float) (rbuff.ru_utime).tv_usec / 1000000.0; tarray[0] = utime - (float) old_utime; stime = (float) (rbuff.ru_stime).tv_sec + (float) (rbuff.ru_stime).tv_usec / 1000000.0; tarray[1] = stime - old_stime; old_utime = utime; old_stime = stime; MEM_UNLOCK(&mut); return (tarray[0] + tarray[1]); }
/* * Function : drv_mcrep_vport_config_set * Purpose : * Set the vport related configuration. * Parameters : * unit : unit id * port : port ID * op : Operation ID * - DRV_MCREP_VPORT_OP_VID * - DRV_MCREP_VPORT_OP_UNTAG_VP * - DRV_MCREP_VPORT_OP_UNTAG_RESET * vport : vport_id * vid : VID * Return : * SOC_E_XXX * * Note : * */ int drv_tbx_mcrep_vport_config_set(int unit, uint32 port, drv_mcrep_control_flag_t op, uint32 vport, uint32 vid) { int rv = SOC_E_NONE; uint32 fld_val32 = 0; vport_vid_map_entry_t *vpvid_map_entry = 0; soc_cm_debug(DK_PORT, "%s,%d,START! port=%x,op=%d,vport%d,vid=%x\n", FUNCTION_NAME(),__LINE__,port,op,vport,vid); /* valid section : assume the port id is verified already */ if (vport >= DRV_TBX_MAX_MCREP_VPORT_NUM){ soc_cm_debug(DK_WARN, "%s,invalid vPort ID %d!\n", FUNCTION_NAME(), vport); return SOC_E_PARAM; } if (vid > DRV_MAX_VPORT_VID){ soc_cm_debug(DK_WARN, "%s,invalid vPort VID %d!\n", FUNCTION_NAME(), vid); return SOC_E_PARAM; } vpvid_map_entry = sal_alloc(sizeof (vport_vid_map_entry_t), "vpvid_map"); sal_memset(vpvid_map_entry, 0, sizeof(vport_vid_map_entry_t)); MEM_LOCK(unit, INDEX(VPORT_VID_MAPm)); rv = MEM_READ_VPORT_VID_MAPm(unit, port, (uint32 *)vpvid_map_entry); if (rv) { soc_cm_debug(DK_WARN, "%s,%d,mem_read failed!!\n", FUNCTION_NAME(), __LINE__); goto config_set_exit; } switch(op){ case DRV_MCREP_VPORT_OP_VID: /* set vPort's VID */ fld_val32 = vid; rv = DRV_MEM_FIELD_SET(unit, INDEX(VPORT_VID_MAPm), _TB_VPVID_FIELD[vport], (uint32 *)vpvid_map_entry, &fld_val32); if (rv){ soc_cm_debug(DK_WARN, "%s,%d,mem_field_set failed!!\n", FUNCTION_NAME(), __LINE__); goto config_set_exit; } break; case DRV_MCREP_VPORT_OP_VID_RESET: /* reset the VID from vPort0-vPort15 on this port : * keep untag vport bmp and reset all other field to 0 */ rv = soc_VPORT_VID_MAPm_field_get(unit, (uint32 *)vpvid_map_entry, VPORT_UNTAGf, &fld_val32); if (rv){ soc_cm_debug(DK_WARN, "%s,%d,mem_field_get failed!!\n", FUNCTION_NAME(), __LINE__); goto config_set_exit; } sal_memset(vpvid_map_entry, 0, sizeof(vport_vid_map_entry_t)); rv = soc_VPORT_VID_MAPm_field_set(unit, (uint32 *)vpvid_map_entry, VPORT_UNTAGf, &fld_val32); if (rv){ soc_cm_debug(DK_WARN, "%s,%d,mem_field_set failed!!\n", FUNCTION_NAME(), __LINE__); goto config_set_exit; } break; case DRV_MCREP_VPORT_OP_UNTAG_VP: /* set untag vPort : * 1. only one vPort is allowed in untag bitmap. * - our design will override original untag vPort by user * requested vPort. * 2. vid in this OP is not used. */ fld_val32 = 1 << vport; rv = soc_VPORT_VID_MAPm_field_set(unit, (uint32 *)vpvid_map_entry, VPORT_UNTAGf, &fld_val32); if (rv){ soc_cm_debug(DK_WARN, "%s,%d,mem_field_set failed!!\n", FUNCTION_NAME(), __LINE__); goto config_set_exit; } break; case DRV_MCREP_VPORT_OP_UNTAG_RESET: /* reset untag vPort bitmap on this port */ fld_val32 = 0; rv = soc_VPORT_VID_MAPm_field_set(unit, (uint32 *)vpvid_map_entry, VPORT_UNTAGf, &fld_val32); if (rv){ soc_cm_debug(DK_WARN, "%s,%d,mem_field_set failed!!\n", FUNCTION_NAME(), __LINE__); goto config_set_exit; } break; case DRV_MCREP_VPORT_OP_VID_UNTAG_RESET: /* reset the vPort VID mapping table entry for this port */ sal_memset(vpvid_map_entry, 0, sizeof(vport_vid_map_entry_t)); break; default: soc_cm_debug(DK_WARN, "%s,invalid op %d!\n", FUNCTION_NAME(), op); rv = SOC_E_PARAM; goto config_set_exit; } rv = MEM_WRITE_VPORT_VID_MAPm(unit, port, (uint32 *)vpvid_map_entry); config_set_exit : MEM_UNLOCK(unit, INDEX(VPORT_VID_MAPm)); sal_free(vpvid_map_entry); return rv; }