lkml.org 
[lkml]   [1997]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
Subject#ifdef __SMP__ in sched.c
Hello,

The beginning of schedule() function from kernel/sched.c looks like this in
2.0.30:

asmlinkage void schedule(void)
{
int c;
struct task_struct * p;
struct task_struct * prev, * next;
unsigned long timeout = 0;
int this_cpu=smp_processor_id();


Shouldn't it rather look like this:

asmlinkage void schedule(void)
{
int c;
struct task_struct * p;
struct task_struct * prev, * next;
unsigned long timeout = 0;
#ifdef __SMP__
int this_cpu=smp_processor_id();
#endif

That saves as at least an assignment "int this_cpu = 0" if __SMP__ is not
defined.

I am perfectly aware that when compiled with -O6 it makes no difference because
the variable is unused so gcc will optimize it away but it still looks nicer
(IMHO) with #ifdef __SMP__.

Tigran.

**********************************************************************
DST International Tel:+44 181 390 5000 www.dstinternational.co.uk

This message and any attachments to it is intended only for the
individual or company to which it is addressed and may contain
information which is privileged, confidential or prohibited from
disclosure or unauthorised use. If the recipient of this
transmission is not the intended recipient, or the employee or agent
responsible for delivering such materials to the intended recipient,
you are hereby notified that any use, any form of reproduction,
dissemination, copying, disclosure, modification, distribution and/or
publication of this e-mail message or its attachments other than by
its intended recipientis strictly prohibited by the sender.

If you have received it in error, please notify us immediately by
telephone on the number above and destroy the message and all copies
in your possession.
**********************************************************************{\rtf1\ansi \deff0\deflang1024{\fonttbl{\f0\froman Tms Rmn;}{\f1\froman Symbol;}{\f2\fswiss Helv;}}
{\colortbl;\red0\green0\blue127;\red0\green127\blue0;\red0\green127\blue127;\red127\green0\blue0;
\red127\green0\blue127;\red127\green127\blue0;\red127\green127\blue127;;\red0\green0\blue255;
\red0\green255\blue0;\red0\green255\blue255;\red255\green0\blue0;\red255\green0\blue255;
\red255\green255\blue0;\red255\green255\blue255;}\paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440
\gutter0 \defformat\sectd \pard\plain {\plain \f0 \cb7 \cf0 \cb7 \cf9 Hello,\
\
\cb7 \cf9 The beginning of schedule() function from kernel/sched.c looks like this in \
\cb7 \cf9 2.0.30:\
\
\cb7 \cf9 asmlinkage void schedule(void)\
\cb7 \cf9 \{\
\cb7 \cf9 int c;\
\cb7 \cf9 struct task_struct * p;\
\cb7 \cf9 struct task_struct * prev, * next;\
\cb7 \cf9 unsigned long timeout = 0;\
\cb7 \cf9 int this_cpu=smp_processor_id();\
\
\
\cb7 \cf9 Shouldn't it rather look like this:\
\
\cb7 \cf9 asmlinkage void schedule(void)\
\cb7 \cf9 \{\
\cb7 \cf9 int c;\
\cb7 \cf9 struct task_struct * p;\
\cb7 \cf9 struct task_struct * prev, * next;\
\cb7 \cf9 unsigned long timeout = 0;\
\cb7 \cf9 #ifdef __SMP__\
\cb7 \cf9 int this_cpu=smp_processor_id();\
\cb7 \cf9 #endif\
\
\cb7 \cf9 That saves as at least an assignment "int this_cpu = 0" if __SMP__ is not \
\cb7 \cf9 defined.\
\
\cb7 \cf9 I am perfectly aware that when compiled with -O6 it makes no difference because \
\cb7 \cf9 the variable is unused so gcc will optimize it away but it still looks nicer \
\cb7 \cf9 (IMHO) with #ifdef __SMP__.\
\
\cb7 \cf9 Tigran.\
\par }}c
\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.024 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site