1
0
Fork 0
forked from nuttx/nuttx-update

nuttx/mm and libc: Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section()

This commit is contained in:
Gregory Nutt 2016-02-14 08:57:01 -06:00
parent f45db0313d
commit 046e39e2c6
4 changed files with 17 additions and 15 deletions

View file

@ -1,7 +1,7 @@
/****************************************************************************
* lib/syslog/lib_setlogmask.c
*
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011-2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -42,7 +42,7 @@
#include <stdint.h>
#include <syslog.h>
#include <arch/irq.h>
#include <nuttx/irq.h>
#include "syslog/syslog.h"
@ -97,11 +97,11 @@ int setlogmask(int mask)
* as interrupts.
*/
flags = irqsave();
flags = enter_critical_section();
oldmask = g_syslog_mask;
g_syslog_mask = (uint8_t)mask;
irqrestore(flags);
leave_critical_section(flags);
return oldmask;
}

View file

@ -2,7 +2,7 @@
* libc/unistd/lib_gethostname.c
*
* Copyright (C) 2015 Stavros Polymenis. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2016 Gregory Nutt. All rights reserved.
* Author: Stavros Polymenis <sp@orbitalfox.com>
* Gregory Nutt <gnutt@nuttx.org>
*
@ -45,7 +45,7 @@
#include <string.h>
#include <unistd.h>
#include <arch/irq.h>
#include <nuttx/irq.h>
/* This file is only compiled if network support is enabled */
@ -119,9 +119,9 @@ int gethostname(FAR char *name, size_t namelen)
* that it could change while we are copying it.
*/
flags = irqsave();
flags = enter_critical_section();
strncpy(name, g_hostname, namelen);
irqrestore(flags);
leave_critical_section(flags);
return 0;

View file

@ -2,7 +2,9 @@
* libc/unistd/lib_gethostname.c
*
* Copyright (C) 2015 Stavros Polymenis. All rights reserved.
* Copyright (C) 2015, 2016 Gregory Nutt. All rights reserved.
* Author: Stavros Polymenis <sp@orbitalfox.com>
* Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -42,7 +44,7 @@
#include <string.h>
#include <unistd.h>
#include <arch/irq.h>
#include <nuttx/irq.h>
/* This file is only compiled if network support is enabled */
@ -118,10 +120,10 @@ int sethostname(FAR const char *name, size_t size)
* are setting it.
*/
flags = irqsave();
flags = enter_critical_section();
strncpy(g_hostname, name, MIN(HOST_NAME_MAX, size));
g_hostname[HOST_NAME_MAX] = '\0';
irqrestore(flags);
leave_critical_section(flags);
return 0;
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* mm/mm_gran/mm_grancritical.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -43,7 +43,7 @@
#include <assert.h>
#include <errno.h>
#include <arch/irq.h>
#include <nuttx/irq.h>
#include <nuttx/mm/gran.h>
#include "mm_gran/mm_gran.h"
@ -83,7 +83,7 @@
void gran_enter_critical(FAR struct gran_s *priv)
{
#ifdef CONFIG_GRAN_INTR
priv->irqstate = irqsave();
priv->irqstate = enter_critical_section();
#else
int ret;
@ -104,7 +104,7 @@ void gran_enter_critical(FAR struct gran_s *priv)
void gran_leave_critical(FAR struct gran_s *priv)
{
#ifdef CONFIG_GRAN_INTR
irqrestore(priv->irqstate);
leave_critical_section(priv->irqstate);
#else
sem_post(&priv->exclsem);
#endif